My trading engine connects to many tickers at once and trades them all simultaneously at high speed. So I execute a lot of trades.
I'm seeing a handful of different kinds of errors repeating in my logs when I trade live against TDA that don't appear to be me at this point. I'm not sure if they are NT8, TDA, or some interaction between the two. I do not see them when running with the simulator. They happen sporadically and appear to be timing-related on the backend. The ticker itself does not appear to be relevant.
Bug 1: Fills after I cancel.
. I cancel an order.
. I get back an OrderState.Cancelled via OnOrderUpdate.
. I then get an OrderState.Filled on the order, with the shares filled.
. I then get an OrderState.Filled on the order with zero shares filled and an error code/msg: OrderFailedCancel: Too late to cancel order.
Bug 2: Spurious OrderFailedChanged errors.
. I have a live limit order.
. I update its price, via Account.Change().
. I get an OrderState.Working with "OrderFailedChange: Order cannot be replaced while in status CANCELED."
. At no point have I canceled the order when I get this response.
. If I cancel the order after I get this error, at some later time, the order cancels normally.
Bug 3: Spurious OrderFailedCancel errors.
. I cancel an order.
. Then I get back OrderState.Accepted.
. Then I get back OrderState.Working with the error: "OrderFailedCancel: Order in state CANCELED cannot be canceled."
. Then OrderState.Accepted.
. Then OrderState.Working.
. Then OrderState.Canceled, as normal.
Bugs 2 + 3 are "harmless", other than that they create numerous misleading error dialogs I cannot turn off. I have a separate thread that looks for these dialogs and kills them as soon as they happen, but it would be better if we didn't get these errors in the first place.
Bug 1 is more serious, b/c I make decisions after an order has been confirmed as canceled. For the order to randomly resurrect and fill later is awkward to deal with. Ideally, we would only get a cancel confirmation when the order is actually canceled with certainty.
Questions:
1. Are these known or expected behaviors somehow? Are there known strategies for dealing with them?
2. Is there something that I am or am not doing on my side that might be causing these behaviors?
3. Is there any chance they can be fixed? If not in the current NT8/TDA interface, then in the one that is being written for the post-Schwab merger? Bug 1 is a genuine problem. I can probably work around it at some point, but it will add needless complexity and I shouldn't have to.
I'd also like to make another plea for the ability to turn off these error pop up dialogs. No user is being helped by the dialogs in my scenario. The errors are false. And the user is me, and I have elaborate logging to very accurately characterize any errors I see, dialogs or not. Needing to have a separate thread that kills 100s (soon to be 1000s) of misleading dialogs a day is a weird place to be as a developer.
Thanks in advance for any help you can provide.
Cheers,
Peter
Comment