Skip to content
All library documents

Handling Hypothetical Fills in an ITCH Order Book Backtest

Article Quant Q&A · Author: user997112

Summary

This question describes a synchronization problem that arises when simulating a strategy against an order-by-order Nasdaq ITCH feed. A hypothetical bid is placed inside the observed spread and becomes the best bid. When a lower-priced displayed bid later trades in the historical feed, the simulator treats that event as a fill for its own better-priced order. The lower-priced order, however, was the one that actually traded in the recorded market.

Replacing the observed order with the simulated fill can leave the reconstructed book inconsistent: the historical feed may provide no later cancellation or trade message for an order that no longer existed in the real market. The question asks whether this mismatch is unavoidable and how a simulator should handle it, but includes no answer or proposed method. Its useful lesson is that replaying historical order events while inserting hypothetical orders requires explicit rules for matching, book state, and counterfactual events. The example highlights a limitation of naïve replay, rather than establishing a definitive solution or assessing any particular backtesting approach.

Key ideas

  • A hypothetical order inserted into a historical order book can change which order would execute first.
  • Historical ITCH messages record actual events, so they do not necessarily describe the counterfactual book after a simulated fill.
  • Removing an observed order to model a hypothetical fill can leave stale state if the feed contains no later event for that order.
  • The document raises a simulator design problem but does not provide a solution.

Tags

Full text
# Backtesting: what happens to real-executed order if mine fills instead?


# Backtesting: what happens to real-executed order if mine fills instead?












I'm writing a backtester and using an order-by-order Nasdaq ITCH feed whilst testing it.

Let's say the bid-ask spread is 100 @ 9-11 @ 100

My strategy inserts an bid order for 100 @ 10 and this becomes the new best bid. I continue parsing the ITCH feed and I see that the 100 @ 9 has traded. This implies had I really placed a bid for 10, that would have traded now.

So instead of removing the bid at 9, I remove my own order and notify my strategy that we were just filled. However, in reality the bid at 9 disappeared and therefore ITCH would never send another message (i.e. cancel) for it because as far as they're concerned, it no longer exists. Therefore I am stuck with this order in the book, which actually shouldn't be there.

Is this situation unavoidable in a backtesting simulation? Or is there something I can/should do?

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.