#NEWLINE# def testUnrealized1( self ) : #NEWLINE# #INDENT# strat = self . createStrategy ( True ) #NEWLINE# strat . addPosEntry ( dt . localize ( datetime . datetime ( 2011 , 1 , 3 , 20 , 53 ) , pytz . utc ) , strat . enterLong , BaseTestCase . TestInstrument , 1 , True ) #NEWLINE# strat . run ( ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . isOpen ( ) , True ) #NEWLINE# self . assertEqual ( strat . enterOkCalls , 1 ) #NEWLINE# self . assertEqual ( strat . exitOkCalls , 0 ) #NEWLINE# self . assertEqual ( strat . enterCanceledCalls , 0 ) #NEWLINE# self . assertTrue ( ( strat . exitCanceledCalls == 0 ) ) #NEWLINE# entryPrice = 127.21 #NEWLINE# lastPrice = strat . getFeed ( ) . getCurrentBars ( ) [ BaseTestCase . TestInstrument ] . getClose ( ) #NEWLINE# self . assertEqual ( strat . getActivePosition ( ) . getReturn ( ) , ( ( lastPrice - entryPrice ) / entryPrice ) ) #NEWLINE# self . assertEqual ( strat . getActivePosition ( ) . getPnL ( ) , ( lastPrice - entryPrice ) )