#NEWLINE# def testBarFeed( self ) : #NEWLINE# #INDENT# events = { #NEWLINE# #INDENT# 'on_bars' : False , #NEWLINE# 'on_order_book_updated' : False , #NEWLINE# 'break' : False , #NEWLINE# 'start' : datetime . datetime . now ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# disp = dispatcher . Dispatcher ( ) #NEWLINE# barFeed = barfeed . LiveTradeFeed ( ) #NEWLINE# disp . addSubject ( barFeed ) #NEWLINE# def on_bars( dateTime , bars ) : #NEWLINE# #INDENT# events [ 'on_bars' ] = True #NEWLINE# if ( events [ 'on_order_book_updated' ] is True ) : #NEWLINE# #INDENT# disp . stop ( ) #NEWLINE# #UNINDENT# #UNINDENT# def on_order_book_updated( orderBookUpdate ) : #NEWLINE# #INDENT# events [ 'on_order_book_updated' ] = True #NEWLINE# if ( events [ 'on_bars' ] is True ) : #NEWLINE# #INDENT# disp . stop ( ) #NEWLINE# #UNINDENT# #UNINDENT# def on_idle( ) : #NEWLINE# #INDENT# if ( ( datetime . datetime . now ( ) - events [ 'start' ] ) . seconds > ( 60 * 5 ) ) : #NEWLINE# #INDENT# disp . stop ( ) #NEWLINE# #UNINDENT# #UNINDENT# barFeed . getNewValuesEvent ( ) . subscribe ( on_bars ) #NEWLINE# barFeed . getOrderBookUpdateEvent ( ) . subscribe ( on_order_book_updated ) #NEWLINE# disp . getIdleEvent ( ) . subscribe ( on_idle ) #NEWLINE# disp . run ( ) #NEWLINE# self . assertTrue ( events [ 'on_bars' ] ) #NEWLINE# self . assertTrue ( events [ 'on_order_book_updated' ] )