<s> import sys <EOL> from datetime import timedelta <EOL> from pandas . io . data import DataReader <EOL> class ProgressBar ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , total_tasks ) : <EOL> self . total_tasks = total_tasks <EOL> self . tasks_completed = <NUM_LIT:0> <EOL> self . progress = "<STR_LIT>" <EOL> def increment ( self ) : <EOL> self . tasks_completed += <NUM_LIT:1> <EOL> for completed_task in xrange ( <NUM_LIT:0> , self . tasks_completed ) : <EOL> self . progress += "<STR_LIT:#>" <EOL> for incomplete_task in xrange ( self . tasks_completed , self . total_tasks ) : <EOL> self . progress += "<STR_LIT:U+0020>" <EOL> def show ( self ) : <EOL> sys . stdout . write ( self . progress + "<STR_LIT:]>" ) <EOL> sys . stdout . flush ( ) <EOL> def update ( self ) : <EOL> self . increment ( ) <EOL> self . show ( ) <EOL> def list_intersection ( left , right ) : <EOL> '''<STR_LIT>''' <EOL> return list ( ( str ( right [ i ] ) for i in xrange ( <NUM_LIT:0> , len ( right ) ) <EOL> if right [ i ] in left is False ) ) <EOL> def stock_price_at_date ( lookup_date , ticker , lag = <NUM_LIT:0> ) : <EOL> '''<STR_LIT>''' <EOL> start = ( lookup_date - timedelta ( days = lag ) ) <EOL> return DataReader ( ticker , start = start , end = lookup_date , <EOL> data_source = '<STR_LIT>' ) . ix [ <NUM_LIT:0> , <NUM_LIT:5> ] <EOL> def quater_maker ( d ) : <EOL> '''<STR_LIT>''' <EOL> d = d . month <EOL> quaters = { <EOL> "<STR_LIT>" : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> "<STR_LIT>" : [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> "<STR_LIT>" : [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] , <EOL> "<STR_LIT>" : [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> } <EOL> return list ( ( key for key in quaters . keys ( ) if d in quaters [ key ] ) ) [ <NUM_LIT:0> ] </s>
