#NEWLINE# def __testIGE_BrokerImpl( self , quantity ) : #NEWLINE# #INDENT# initialCash = ( 42.09 * quantity ) #NEWLINE# barFeed = yahoofeed . Feed ( ) #NEWLINE# barFeed . addBarsFromCSV ( 'ige' , common . get_data_file_path ( 'sharpe-ratio-test-ige.csv' ) ) #NEWLINE# strat = strategy_test . TestStrategy ( barFeed , initialCash ) #NEWLINE# strat . setUseAdjustedValues ( True ) #NEWLINE# strat . setBrokerOrdersGTC ( True ) #NEWLINE# stratAnalyzer = sharpe . SharpeRatio ( ) #NEWLINE# strat . attachAnalyzer ( stratAnalyzer ) #NEWLINE# strat . getBroker ( ) . getFillStrategy ( ) . setVolumeLimit ( None ) #NEWLINE# order = strat . getBroker ( ) . createMarketOrder ( broker . Order . Action . BUY , 'ige' , barFeed , True ) #NEWLINE# order . setGoodTillCanceled ( True ) #NEWLINE# strat . getBroker ( ) . submitOrder ( order ) #NEWLINE# strat . addOrder ( datetime . datetime ( 2007 , 11 , 13 ) , strat . getBroker ( ) . createMarketOrder , broker . Order . Action . SELL , 'ige' , quantity , True ) #NEWLINE# strat . run ( ) #NEWLINE# self . assertEqual ( round ( strat . getBroker ( ) . getCash ( ) , 2 ) , ( initialCash + ( ( 127.64 - 42.09 ) * quantity ) ) ) #NEWLINE# self . assertEqual ( strat . orderUpdatedCalls , 4 ) #NEWLINE# self . assertEqual ( round ( stratAnalyzer . getSharpeRatio ( 0.04 , True ) , 4 ) , 0.7889 ) #NEWLINE# self . assertEqual ( round ( stratAnalyzer . getSharpeRatio ( 0.04 , False ) , 4 ) , 0.0497 )