I have attached a screenshot of a live trade gone wrong because of a race condition.
When the 'order reject' was received by NinjaTrader, it tried to close the position but failed to do so and exited (stopped the strategy) with the trade still running.
Here's a summary of what happened:
1) Strategy tried to change a pending limit order.
2) In exactly the second it submitted the change request, the initial order got filled by the exchange.
3) The change order was then 'Rejected' because the initial order has been filled.
4) Ninja thinks everything went nuclear, because of the order reject and tries to close the position while turning off the strategy.
5) Ninja cannot close the position ... *Possibly* because the 'Filled' event didn't arrive yet ?!?!
So there are 2 issues here:
- Race Condition (how to fix this?)
- Ninja terminating a strategy without closing the position, deadly!
Thank you very much for any help,
dax3k
Comment