#NEWLINE# def testLongPosition( self ) : #NEWLINE# #INDENT# strat = self . createStrategy ( ) #NEWLINE# strat . addPosEntry ( datetime . datetime ( 2000 , 11 , 3 ) , strat . enterLong , BaseTestCase . TestInstrument , 1 , False ) #NEWLINE# strat . addPosExitMarket ( datetime . datetime ( 2000 , 11 , 7 ) ) #NEWLINE# strat . run ( ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . isOpen ( ) , False ) #NEWLINE# self . assertEqual ( strat . enterOkCalls , 1 ) #NEWLINE# self . assertEqual ( strat . exitOkCalls , 1 ) #NEWLINE# self . assertEqual ( strat . orderUpdatedCalls , 4 ) #NEWLINE# self . assertTrue ( ( round ( strat . getBroker ( ) . getCash ( ) , 2 ) == round ( ( ( 1000 + 27.37 ) - 30.69 ) , 2 ) ) ) #NEWLINE# self . assertTrue ( ( round ( strat . getResult ( ) , 3 ) == ( - 0.108 ) ) ) #NEWLINE# self . assertTrue ( ( round ( strat . getNetProfit ( ) , 2 ) == round ( ( 27.37 - 30.69 ) , 2 ) ) ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . getAge ( ) . days , 2 )