#NEWLINE# def testPartialFillGTC1( self ) : #NEWLINE# #INDENT# instrument = 'orcl' #NEWLINE# bf = TestBarFeed ( bar . Frequency . DAY ) #NEWLINE# bars = [ bar . BasicBar ( datetime . datetime ( 2000 , 1 , 1 ) , 10 , 10 , 10 , 10 , 10 , 10 , bar . Frequency . DAY ) , bar . BasicBar ( datetime . datetime ( 2000 , 1 , 2 ) , 11 , 11 , 10 , 10 , 10 , 10 , bar . Frequency . DAY ) , bar . BasicBar ( datetime . datetime ( 2000 , 1 , 3 ) , 12 , 12 , 10 , 10 , 10 , 10 , bar . Frequency . DAY ) , bar . BasicBar ( datetime . datetime ( 2000 , 1 , 4 ) , 13 , 13 , 10 , 10 , 10 , 10 , bar . Frequency . DAY ) , bar . BasicBar ( datetime . datetime ( 2000 , 1 , 5 ) , 14 , 14 , 10 , 10 , 10 , 10 , bar . Frequency . DAY ) , bar . BasicBar ( datetime . datetime ( 2000 , 1 , 6 ) , 15 , 15 , 10 , 10 , 10 , 10 , bar . Frequency . DAY ) ] #NEWLINE# bf . addBarsFromSequence ( instrument , bars ) #NEWLINE# strat = TestStrategy ( bf , instrument , 1000 ) #NEWLINE# strat . addPosEntry ( datetime . datetime ( 2000 , 1 , 1 ) , strat . enterLongStop , instrument , 12 , 4 , True ) #NEWLINE# strat . addPosExitMarket ( datetime . datetime ( 2000 , 1 , 4 ) ) #NEWLINE# strat . run ( ) #NEWLINE# self . assertEqual ( bf . enterOkCalls , 1 ) #NEWLINE# self . assertEqual ( strat . enterCanceledCalls , 0 ) #NEWLINE# self . assertEqual ( strat . exitOkCalls , 1 ) #NEWLINE# self . assertEqual ( strat . exitCanceledCalls , 0 ) #NEWLINE# self . assertEqual ( len ( strat . posExecutionInfo ) , 2 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 0 ] . getPrice ( ) , 12 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 0 ] . getQuantity ( ) , 2 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 0 ] . getCommission ( ) , 0 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 0 ] . getDateTime ( ) , datetime . datetime ( 2000 , 1 , 3 ) ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 1 ] . getPrice ( ) , 15 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 1 ] . getQuantity ( ) , 2 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 1 ] . getCommission ( ) , 0 ) #NEWLINE# self . assertEqual ( strat . posExecutionInfo [ 1 ] . getDateTime ( ) , datetime . datetime ( 2000 , 1 , 6 ) ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . isOpen ( ) , False ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . getShares ( ) , 0 ) #NEWLINE# self . assertTrue ( strat . positions [ 0 ] . getEntryOrder ( ) . isFilled ( ) ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . getEntryOrder ( ) . getFilled ( ) , 4 ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . getEntryOrder ( ) . getRemaining ( ) , 0 ) #NEWLINE# self . assertTrue ( strat . positions [ 0 ] . getExitOrder ( ) . isFilled ( ) ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . getExitOrder ( ) . getFilled ( ) , 4 ) #NEWLINE# self . assertEqual ( strat . positions [ 0 ] . getExitOrder ( ) . getRemaining ( ) , 0 )