We are testing our new strategy in conjunction with IB TWS. The documentation says that it is better to use the OnExecutionUpdate method to correctly process orders flow coming from IB.
We didn't have any problems while working with small amount of stocks but we noticed a problem while working with big amount of stocks.
For example, we have set StopLoss. When it starts to be executed in parts, the method should be called in the order in which the order is filled. As a result, the last method call does not correspond to reality. We have made the log for onExecutionUpdate and onOrderUpdate to understand where the problem is and found out that very often the closing order in the flow doesn't call OnExectuionUpdate.
Here is a screenshot with the order of calls and parameter passing.
It shows that at iteration 13 ex.Postion=0, i.e. the order is filled, while the status of PartFilled and ex.Order.Filled is equal to line 12. This is not true. No calls of the OnExecutionUpdate method were made after 13 iteration. If at this moment we look at the data of the order itself, there is the same information, but if we look at Position.Quantity, there is already 0.
This problem doesn't always occur, but if the filling is done in parts, in 90% of cases it occurs.
Please advise how to fix it?
Comment