I am running into an issue where my strategy is leaving "dead" / "stuck" orders out in the market, that are floating around for hours and not filling. I have found numerous threads on this issue and I believe this is caused when the strategy attempts to change/cancel a live order at the same instant it is being filled. My strategy is a higher frequency strategy that triggers/changes orders with the OnMarketData() method, so this is happening very often.
Is there any way to avoid this? Could I add some logic to the strategy to check order state before attempting to change/cancel?
I understand how to clear these stuck orders out of Sim101, and I understand that these are less likely to happen in a real account as orders are hosted on the broker's servers. It would really be nice to find a way to avoid this so that I can actually test this strategy before going live. It would also be nice to not need to clear out the DB on a daily basis.
Comment