I am having an issue with getting the correct number of Filled Contracts in OnExecution.
My understanding is that execution.order.filled will return the actual number filled, not the original order size.
So if I buy 11 contracts @ Market in a thin Market (dec Gold ZG) for instance the order is likely to be filled in pieces, like so
3 Filled
5 Filled
2 Filled
1 Filled
-----
11
FYI: The fills are shown correctly in the Control Center Executions tab
Each fill generates a call to the OnExecution Method correctly (4 times)
The problem is that execution.order.filled always returns 11 (even though only 3 are initially filled the first time in, 5 the second time, etc)
FYI: execution.order.quantity always returns 11 as well.
This is really throwing off my code because I need to update the stop as the order gets filled.
Thanks for any help on this. BTW this happens live trading and in replay.
Here is a snipet of my code
protectedoverridevoid OnExecution(IExecution execution)
{
//Always prints 11 for above example
Print("execution.Order.Filled: " + execution.Order.Quantity);
if ( (StopOrder != null && StopOrder.Token == execution.Order.Token) )
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
{
PositionQty = PositionQty - execution.Order.Filled; //always subtracts 11
Comment