View Full Version : Strategy ATM "No Outstanding Orders" Check
07-23-2007, 06:25 AM
When running a tick-update NinjaScript strategy, what is the best way to suppress the placement of an ATM command submission until 1) the ATM market position is flat and 2) there are no active ATM-based orders. GetAtmStrategyMarketPosition() is part of the solution but there seems to be no straightforward way to ensure that there are no outstanding orders . . . keeping in mind that previously placed orders could be filled, cancelled, rejected, etc. An example would be appreciated. Thanks.
07-23-2007, 07:03 AM
Unfortunately there is no guaranteed method to ensure that all orders internally generated from an initiated ATM strategy (stops and targets) reach a terminated status. The ATM strategy itself when flat/terminated takes care of cancelling any pending orders but there is a chance that you get inflight fills prior to the order actually reaching a cancelled state. This is not frequent but can happen.
NT 6.5 provides full order state events for NinjaScript generated orders (not ATM) which can be monitored.
07-23-2007, 07:59 AM
Thanks Ray. If you don't mind, I have a few of follow-up questions.
Under certain conditions, I can submit an AtmStrategyCancelEntryOrder() that will cancel the Entry order as well as the OCO targets and stops, but I suspect I would still be at risk for these inflight issues should I then try to place a new ATM command on the next tick? Is this correct?
It seems to me that with the use of GetAtmStrategyStopTargetOrderStatus() and GetAtmStrategyEntryOrderStatus() methods it is possible to inspect the orderstate of the last OrderName / AtmStrategyID to determine if all orders have reached a terminal status (e.g., Filled, Cancelled, Rejected). Is this a reliable approach to avoid any inflight issues? Is it too processing intensive to consider for tick-by-tick operations?
Will 6.5 include some convenience functionality for the common use-case to easily know when there are no outstanding orders vs having to inspect each entry, exit, and remaining partial fill order?
07-23-2007, 10:46 AM
2. No way with an ATM strategy to detect inflight executions
3. In NT 6.5 we will expand NinjaScript to provide official support for additional events such as order state, executions, position changes etc... This will allow an advanced programmer to code their own ATM like functionality with as much exception handling as they see fit.
07-23-2007, 11:18 AM
Regarding #2, I agree there is "No way with an ATM strategy to detect inflight executions" per se. What I am specifically asking is if I am able to inspect all entry and exit orders associated with the last executed ATM command and determine each is of a terminal orderstate (e.g., filled, cancelled, or rejected) before submitting the next ATM order, is it likely I can minimize or even eliminate the risk of inflight executions?
I apprecate where you are heading with 6.5 but could use a viable interim solution for ATM operations that allows interaction with the orders on the DOM without impacting the underlying strategy.
07-23-2007, 01:59 PM
You can since ATM strategies could be terminated while 'pending cancel' stop/target orders are filled inflight. You can not query a terminated strategy's orders. This is a limitation.