<s> """<STR_LIT>""" <EOL> import datetime <EOL> import common <EOL> from pyalgotrade import eventprofiler <EOL> from pyalgotrade . barfeed import yahoofeed <EOL> class Predicate ( eventprofiler . Predicate ) : <EOL> def __init__ ( self , eventDates ) : <EOL> self . __dates = eventDates <EOL> def eventOccurred ( self , instrument , bards ) : <EOL> ret = False <EOL> if bards [ - <NUM_LIT:1> ] . getDateTime ( ) . date ( ) in self . __dates : <EOL> ret = True <EOL> return ret <EOL> class EventProfilerTestCase ( common . TestCase ) : <EOL> def testNoEvents ( self ) : <EOL> feed = yahoofeed . Feed ( ) <EOL> feed . addBarsFromCSV ( "<STR_LIT>" , common . get_data_file_path ( "<STR_LIT>" ) ) <EOL> predicate = Predicate ( [ ] ) <EOL> eventProfiler = eventprofiler . Profiler ( predicate , <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> eventProfiler . run ( feed , True ) <EOL> self . assertEqual ( eventProfiler . getResults ( ) . getEventCount ( ) , <NUM_LIT:0> ) <EOL> def testEventsOnBoundary ( self ) : <EOL> feed = yahoofeed . Feed ( ) <EOL> feed . addBarsFromCSV ( "<STR_LIT>" , common . get_data_file_path ( "<STR_LIT>" ) ) <EOL> dates = [ ] <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:5> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:6> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:7> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:10> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> dates . append ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> predicate = Predicate ( dates ) <EOL> eventProfiler = eventprofiler . Profiler ( predicate , <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> eventProfiler . run ( feed , True ) <EOL> self . assertEqual ( eventProfiler . getResults ( ) . getEventCount ( ) , <NUM_LIT:0> ) <EOL> def testOneEvent ( self ) : <EOL> feed = yahoofeed . Feed ( ) <EOL> feed . addBarsFromCSV ( "<STR_LIT>" , common . get_data_file_path ( "<STR_LIT>" ) ) <EOL> predicate = Predicate ( [ datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:11> ) ] ) <EOL> eventProfiler = eventprofiler . Profiler ( predicate , <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> eventProfiler . run ( feed , True ) <EOL> self . assertEqual ( eventProfiler . getResults ( ) . getEventCount ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( eventProfiler . getResults ( ) . getValues ( <NUM_LIT:0> ) [ <NUM_LIT:0> ] , <NUM_LIT:1.0> ) <EOL> self . assertEqual ( round ( eventProfiler . getResults ( ) . getValues ( <NUM_LIT:5> ) [ <NUM_LIT:0> ] , <NUM_LIT:5> ) , round ( <NUM_LIT> , <NUM_LIT:5> ) ) </s>
