GT order may have a life span of more than one days. A GT order may also possibly live through multiple FIX sessions.
A GT order must have a unique ClOrdID across multiple FIX sessions. It is recommended to encode date information into the ClOrdID of GT orders.
QWFIX trading system offers full GT order support.
In QWFIX, it is assumes both the buy side and sell side maintain a database of all open GT orders.
Both buy side and sell side needs to implement FIXSessionOrderManagerGTOrderHandler for GT order handling. There is only one method call defined in FIXSessionOrderManagerGTOrderHandler, FIXSessionOrderManagerGTOrderHandler.queryRestatedGTOrder. Method queryRestatedGTOrder takes an execution report FIX message. It returns a FIXOrderType. If the execution message represents a GT order, a valid FIXOrderType will be returned; otherwise FIXOrderType.INVALID will be returned.
FIXSessionOrderManager.setGTOrderHandler() is used to set the GT order handler for the specific session.
It is recommended the sell side start a thread to synchronize all open GT orders immediately after the FIX session is started (in respond to FIXSessionStatusListener.sessionStarted event). FIX 4.2+ defined a "Restated" execution report specifically for communicating GT orders to buy side.
Note, the engine process may be killed and restarted during the session life cycle. The GT order only need to be transmitted once. It is recommended that application check whether the specific ClOrdID is available before creating and sending the GT order to buy side.
Whenever the buy side receives an execution report with unknown ClOrdID, the FIXSessionOrderManagerGTOrderHandler.queryRestatedGTOrder will be triggered. Buy side application is required to hook up their own implementation of the event handler.
Basically buy side event handler is only required to provide the following information:
If the event handler returns "true", a new GT order will be automatically constructed and added, which will in turn trigger FIXSessionOrderManagerCommonListener.orderAdded event.
If the answer is "no", the message will be ignored and an error alert will be logged.
The sell side peocess may be killed and restarted during the trading session. When it is restarted, a recovery process may be performed by "replaying" all historical messages. Usually the order manager can automatically reconstruct all orders from the historical FIX message replay. However, it can not tell whether an execution report is a restated GT order or just an invalid execution.
In QWFIX, whenever an execution report is encountered during recovery process, the FIXSessionOrderManagerGTOrderHandler.queryRestatedGTOrder event is triggered. The sell side should behave similar to the buy side. Note, the event is only triggered during recovery process.