#NEWLINE# def testBitcoinChartsFeed( self ) : #NEWLINE# #INDENT# class TestStrategy ( strategy . BaseStrategy ) : #NEWLINE# #INDENT# def __init__( self , feed , brk ) : #NEWLINE# #INDENT# strategy . BaseStrategy . __init__ ( self , feed , brk ) #NEWLINE# self . pos = None #NEWLINE# #UNINDENT# def onBars( self , bars ) : #NEWLINE# #INDENT# if ( not self . pos ) : #NEWLINE# #INDENT# self . pos = self . enterLongLimit ( 'BTC' , 5.83 , 1 , True ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# barFeed = btcbarfeed . CSVTradeFeed ( ) #NEWLINE# barFeed . addBarsFromCSV ( tc_common . get_data_file_path ( 'bitstampUSD.csv' ) ) #NEWLINE# brk = broker . BacktestingBroker ( 100 , barFeed ) #NEWLINE# strat = TestStrategy ( barFeed , brk ) #NEWLINE# strat . run ( ) #NEWLINE# self . assertEquals ( strat . pos . getShares ( ) , 1 ) #NEWLINE# self . assertEquals ( strat . pos . entryActive ( ) , False ) #NEWLINE# self . assertEquals ( strat . pos . isOpen ( ) , True ) #NEWLINE# self . assertEquals ( strat . pos . getEntryOrder ( ) . getAvgFillPrice ( ) , 5.83 )