I got it working great and have been using the replay connection to test out various scenarios. I'm using the unmanaged approach.
During my testing I submitted a Sell Limit entry order below current price - it was by accident, actually; I got some numbers wrong: its a scenario that I had not considered to test.
Although sell limit below current price is an unusual scenario it is a valid one - since an order to sell at a limit price will sell at the defined limit price.... or better! Thus submitting a Sell Limit below current price results in an immediate fill. As current price is even higher than the limit price then this is a better price to sell at and so the order is entered and immediately filled. When I did this I noticed that I subsequently had a naked order with no stop or target...
The problem is that the technique prescribed in the examples depends on the utilisation of a a reference to the Entry Order. We check that the Order being handled by the OnExecution/OrderUpdate Callback is, in-fact, our entry order; and if so: submit our stop and target orders.
Unfortunately, in the scenario I have described, the entry-order has been submitted, filled, and is working... and the OnOrderUpdate and OnExecutionUpdate callbacks have fired even before the SubmitOrderUnmanaged method has returned me a reference which I can store and check. Its too late because it has already happened.
Any thoughts on the best way to handle this edge case?
Comment