I had a extrange case where a stop order was filled in multiple lots. My code automatically adjust stop orders to the current share number because I also have at the same time profit limit orders therefore decreasing the number of shares in the current position. Where there were about 94 shares left I executed an order change and instead I end up with a buy order in IB.
Unfortunatelly I did not save the log from NinjaTrader but I have the log I generated from my code in TS plus the audit trail from IB that shows the partial filled orders plus the new order in the other direction. Here I am pasting my trace and IB audit trail.
Thanks,
Moscu
MY TRACE
1) Stop Order sent
400 , SHR= 400 , PRVSHR= 0 , ORD=SELL-35.45-35.34-400
10/10/2008 , 1006 , 1 , 10:06:42 AM , 35.53 , PLACE , BUY-SX H StopLoss-T35-1006-1-STOP-35.59 , SX H StopLoss ,ORD=BUY-35.59-0.00-400 , MP=-1 , RTN=0
2) Order partially filled
10/10/2008 , 1007 , 29 , 10:07:13 AM , 35.62 , WAITING , BUY-SX H StopLoss-T35-1006-1-STOP-35.59, status=PartFilled , MP= -1 Fill-Price= 35.62 , Filled= 306 , SHR= 400 , PRVSHR= 400 , ORD=BUY-35.59-0.00-400
10/10/2008 , 1007 , 30 , 10:07:13 AM , 35.62 , WAITING , BUY-SX H StopLoss-T35-1006-1-STOP-35.59, status=PartFilled , MP= -1 Fill-Price= 35.62 , Filled= 306 , SHR= 400 , PRVSHR= 400 , ORD=BUY-35.59-0.00-400
10/10/2008 , 1007 , 31 , 10:07:13 AM , 35.62 , WAITING , BUY-SX H StopLoss-T35-1006-1-STOP-35.59, status=PartFilled , MP= -1 Fill-Price= 35.62 , Filled= 306 , SHR= 400 , PRVSHR= 400 , ORD=BUY-35.59-0.00-400
3) Change sent when lest 94 shares to be filled.
10/10/2008 , 1007 , 32 , 10:07:14 AM , 35.63 , CHANGE , BUY-SX H StopLoss-T35-1006-1-STOP-35.59 , SX H StopLoss ,ORD=BUY-35.63-0.00-94 , MP=-1 , RTN=0
4) confirmation received from NInja for 94 shares
10/10/2008 , 1007 , 32 , 10:07:14 AM , 35.63 , FILLED , BUY-SX H StopLoss-T35-1006-1-STOP-35.59, status=Filled , MP= -1 Fill-Price= 35.63 , Filled= 400 , SHR= 94 , PRVSHR= 400 , ORD=BUY-35.63-0.00-94
IB Audit trail
1) Place stop order
PlaceOrder 20081010-14:06:34 2147439180.0 - Buy 400 PRU Stop - DAY AuxPrice= 35.59; Account= *******; StopPrice= 35.59; 6115 = 0; OptionAcct= c; DdeId= 3605; ServerId= 0; SecurityType= CS; SecurityID= PRU; SecurityIDSource= 101; ContractMultiplier= 1.0; 6436 = 0; ExDestination= BEST; 6210 = BEST; ContractID= 13865082; EOrder= Socket; Currency= USD; 6211 = ; 6238 = ;
Acknowledged 20081010-14:07:04 2147439180.0 00044338.00011385.48eede60.0001 Buy 400 PRU Stop - DAY ExecID= 70533.1223647624.0; ExecType= New; ExecTransType= Status; OrdStatus= New; 6210 = BEST; AuxPrice= 35.59; StopPrice= 35.59; CumQty= 0; LeavesQty= 400; AvgPx= 0; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/ARCA/26/PRU/PRU; TransactTime= 20081010-14:07:04; DdeId= 3605; Rule80A= AgenySingleOrder; ContractID= 13865082; Currency= USD; Exchange= BEST; 6116 = 0; OptionAcct= c; CustomerOrFirm= Customer; WorkingIndicator: Y; 6205 = 1; 6434 = 0; 6115 = 0; EOrder= Socket; 6419 = IB;
Acknowledged 20081010-14:07:04 2147439180.0 00044338.00011385.48eede60.0001 Buy 400 PRU Stop - DAY ExecID= 70533.1223647624.1; ExecType= New; ExecTransType= New; OrdStatus= New; ExDestination= NYSE; SecurityExchange= NYSE; AuxPrice= 35.59; CumQty= 0; LeavesQty= 400; AvgPx= 0; SecurityType= CS; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/ARCA/26/PRU/PRU; TransactTime= 20081010-14:07:04; DdeId= 3605; OptionAcct= c; CustomerOrFirm= Customer;
2) Order partial Filled starts
PartiallyFilled 20081010-14:07:05 2147439180.0 00044338.00011385.48eede60.0001 Buy 100 PRU Stop - DAY ExecID= 0001f028.48ef68e3.01.01; ExecType= PartiallyFilled; ExecTransType= New; OrdStatus= PartiallyFilled; ExDestination= NYSE; SecurityExchange= NYSE; AuxPrice= 35.59; LastMarket= NYSE; CumQty= 100; LeavesQty= 300; AvgPx= 35.61; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/NYSE/26/PRU/PRU; TransactTime= 20081010-14:07:05; DdeId= 3605; ContractID= 13865082; Currency= USD; OptionAcct= c; CustomerOrFirm= Customer; EOrder= Socket; 6419 = IB;
PartiallyFilled 20081010-14:07:05 2147439180.0 00044338.00011385.48eede60.0001 Buy 6 PRU Stop - DAY ExecID= 0000d3fc.48ef6341.01.01; ExecType= PartiallyFilled; ExecTransType= New; OrdStatus= PartiallyFilled; ExDestination= BATS; SecurityExchange= BATS; AuxPrice= 35.59; LastMarket= BATS; CumQty= 106; LeavesQty= 294; AvgPx= 35.61; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/BATS/26/PRU/PRU; TransactTime= 20081010-14:07:05; DdeId= 3605; ContractID= 13865082; Currency= USD; OptionAcct= c; CustomerOrFirm= Customer; EOrder= Socket; 6419 = IB;
PartiallyFilled 20081010-14:07:05 2147439180.0 00044338.00011385.48eede60.0001 Buy 100 PRU Stop - DAY ExecID= 0000d3fc.48ef6342.01.01; ExecType= PartiallyFilled; ExecTransType= New; OrdStatus= PartiallyFilled; ExDestination= BATS; SecurityExchange= BATS; AuxPrice= 35.59; LastMarket= BATS; CumQty= 206; LeavesQty= 194; AvgPx= 35.6149; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/BATS/26/PRU/PRU; TransactTime= 20081010-14:07:05; DdeId= 3605; ContractID= 13865082; Currency= USD; OptionAcct= c; CustomerOrFirm= Customer; EOrder= Socket; 6419 = IB;
PartiallyFilled 20081010-14:07:05 2147439180.0 00044338.00011385.48eede60.0001 Buy 100 PRU Stop - DAY ExecID= 0000da5f.48ef431c.01.01; ExecType= PartiallyFilled; ExecTransType= New; OrdStatus= PartiallyFilled; ExDestination= ISLAND; SecurityExchange= ISLAND; AuxPrice= 35.59; LastMarket= ISLAND; CumQty= 306; LeavesQty= 94; AvgPx= 35.6165; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/ISLAND/26/PRU/PRU; TransactTime= 20081010-14:07:05; DdeId= 3605; ContractID= 13865082; Currency= USD; OptionAcct= c; CustomerOrFirm= Customer; EOrder= Socket; 6419 = IB;
PartiallyFilled 20081010-14:07:05 2147439180.0 00044338.00011385.48eede60.0001 Buy 0 PRU Stop - DAY ExecID= 70533.1223647625.0; ExecType= PartiallyFilled; ExecTransType= Status; OrdStatus= PartiallyFilled; ExDestination= ISLAND; SecurityExchange= ISLAND; 6210 = BEST; AuxPrice= 35.59; StopPrice= 35.59; CumQty= 306; LeavesQty= 94; AvgPx= 35.6165; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/ARCA/26/PRU/PRU; TransactTime= 20081010-14:07:05; DdeId= 3605; Rule80A= AgenySingleOrder; ContractID= 13865082; Currency= USD; Exchange= BEST; 6116 = 0; OptionAcct= c; CustomerOrFirm= Customer; WorkingIndicator: Y; 6205 = 1; 6434 = 0; 6115 = 0; EOrder= Socket; 6419 = IB;
3) here the order was filled by IB with the total of 400
Filled 20081010-14:07:06 2147439180.0 00044338.00011385.48eede60.0001 Buy 94 PRU Stop 35.69 DAY ExecID= 00012c64.48ef1cd5.01.01; ExecType= Filled; ExecTransType= New; OrdStatus= Filled; ExDestination= ARCA; SecurityExchange= ARCA; AuxPrice= 35.59; LastMarket= ARCA; CumQty= 400; LeavesQty= 0; AvgPx= 35.6338; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/ARCA/26/PRU/PRU; TransactTime= 20081010-14:07:06; DdeId= 3605; ContractID= 13865082; Currency= USD; OptionAcct= c; CustomerOrFirm= Customer; EOrder= Socket; 6419 = IB;
4)Here the order change comes as a buy order into IB
PlaceOrder 20081010-14:07:05 2147439181.0 - Buy 94 PRU Stop - DAY AuxPrice= 35.68; Account= *******; StopPrice= 35.68; 6115 = 0; OptionAcct= c; DdeId= 3606; ServerId= 0; SecurityType= CS; SecurityID= PRU; SecurityIDSource= 101; ContractMultiplier= 1.0; 6436 = 0; ExDestination= BEST; 6210 = BEST; ContractID= 13865082; EOrder= Socket; Currency= USD; 6211 = ; 6238 = ;
Acknowledged 20081010-14:07:07 2147439181.0 00044338.00011385.48eede66.0001 Buy 94 PRU Stop - DAY ExecID= 70533.1223647627.0; ExecType= New; ExecTransType= Status; OrdStatus= New; 6210 = BEST; AuxPrice= 35.68; StopPrice= 35.68; CumQty= 0; LeavesQty= 94; AvgPx= 0; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/ARCA/26/PRU/PRU; TransactTime= 20081010-14:07:07; DdeId= 3606; Rule80A= AgenySingleOrder; ContractID= 13865082; Currency= USD; Exchange= BEST; 6116 = 0; OptionAcct= c; CustomerOrFirm= Customer; WorkingIndicator: Y; 6205 = 1; 6434 = 0; 6115 = 0; EOrder= Socket; 6419 = IB;
Filled 20081010-14:07:07 2147439181.0 00044338.00011385.48eede66.0001 Buy 94 PRU Stop 35.68 DAY ExecID= 0000d3fc.48ef6345.01.01; ExecType= Filled; ExecTransType= New; OrdStatus= Filled; ExDestination= BATS; SecurityExchange= BATS; AuxPrice= 35.68; LastMarket= BATS; CumQty= 94; LeavesQty= 0; AvgPx= 35.68; SecurityType= CS; ClearingFirm= 534; Account= *******; ConQPath= PRU/STK/USD/13865082/33556/BATS/26/PRU/PRU; TransactTime= 20081010-14:07:07; DdeId= 3606; ContractID= 13865082; Currency= USD; OptionAcct= c; CustomerOrFirm= Customer; EOrder= Socket; 6419 = IB;
Comment