Dareminator,
Thanks for the detailed post.
Seems like you went through a Herculean effort to work around the OQ order handling bugs.
Obviously, it would be far, far better if SmartQuant would fix these bugs so that the rest of us, and future customers, all don't have to do the same thing. I am also concerned that even if one can patch around things, and it tests OK, what other bugs are lurking in a patched-up order handling that haven't occurred yet in necessarily limited testing and live trading? Often, if code has known problems in state processing, when it is cleaned up and rigorously tested with tough and thorough test benches, multiple bugs are cleaned out, even ones that have yet to be found.
One can easily imagine devestating consequences in a high frequency long/short strategy that goes awry because of misprocessed order handling. E.G, what if a partial or full fill message gets dropped or misprocessed?
I will request an update from Smartquant on their debugging effort:
http://www.smartquant.com/forums/viewto ... highlight=
As to your post, here are some specific comments/questions:
Quote:
When I cancel order1 in an OCA group, order2 is also cancelled in TWS, but stays in a PendingCancel status in OQ. What I did: when I want to cancel an OCA pair, I call Cancel() on both...
I have done the same thing. Downside: more messages from TWS and in the audit trail, saying the cancel order has been rejected.
Quote:
the rejected order is an exit order, the code would resubmit it at the next bar -- but that should not happen, as there would be no reason for an exit order to be rejected
Why would their be a difference between the possible rejection of an entry vs. an exit order?
Quote:
An order is partially filled and Portfolio is not updated. What I did: I handle OnOrderPartiallyFilled event. I keep track of my position...
So you keep a side-count of partially filled orders? By using portfolio.add() or just in your internal database? In either case, and if the order does go to the orderdone state, you have to undo this as the portfolio.positions will get updated by OQ?
Quote:
I also have a panic timer (OnTimer) that, if triggered, means the code didn't press the red button in time (something is not right). The only case I see this on a regular basis is not receiving a 1-minute bar, either because there were no trades and OQ didn't generate a bar, or IB market data was interrupted...
You may also want to look at the provider error messages using OnError(), and look for at a minimum codes 2103 (Market data farm connection is broken) and 1100 (Connectivity between IB and TWS has been lost). This way you can get a little faster response time on knowing there is a problem, and suspend placing orders and/or sound the alarm...
Another safety check I have thought of is to perdiocially use DataManager.GetBrokerInfo("IB").Accounts to check against the internal Portfolio.Positions to see if there is a mismatch, and sound the alarm if there is. Haven't coded it up yet, and there are some timing issues.
Regards,
DFT