Back to blog
October 1, 20267 min read

Order Book Data in a Trading Bot: Why DOM Signals Barely Backtest

The order book and the footprint look like two views of the same thing, but they show fundamentally different things. The book shows resting limit orders - announced intent. The footprint shows executions - what actually took place. For manual observation that difference is a nuance. For a bot it is the decisive point.

Resting liquidity commits no one

A limit order in the book binds nobody. It can be cancelled before price ever reaches it, and that happens constantly. A conspicuously large order may be genuine interest - or an order that rests exactly as long as it takes for someone to react to it. A rule along the lines of a large order at a level counts as support therefore rests on information that can dissolve in the same second it was read. Executed volume doesn't have that problem: what traded, traded.

The bigger problem is the history

The second difference weighs even heavier in practice. Executions are recorded in full - every trade with price, size and side. The state of the order book over time, by contrast, is an entirely different kind of data: it requires every addition, modification and cancellation at every price level, and that is not part of the usual historical data behind a chart. A rule based on the state of the book therefore usually cannot be checked against the same history as a rule based on executed data. That isn't a programming question, it's a data question.

What follows from that in practice

  • A DOM rule that was never checked against history remains an assumption - even when it looks plausible in live operation
  • If you want to run one anyway, log your own snapshots of the book state from day one and build your own history
  • Store only the figures the rule actually needs - a complete recording of the book grows very fast
  • Keep live observation and backtesting clearly apart rather than producing a token test over a handful of days

Want an order book evaluation that fits your approach?

Describe what in the book should trigger a reaction - the feasibility check and quote are free and non-binding.

Request a project

More robust: change rather than size

The static size of an order is the most fragile piece of information in the book. Changes over time are more reliable, and above all the cross-check against executions: if a large order stays put while aggressive trading hits it, that's an observable fact - the volume was executed and the order is still there. If it vanishes without meaningful trading against it, it evidently wasn't meant to be filled. In both cases the confirmation comes from the executed data, not from the book itself.

For how that taking in of aggression becomes visible in the footprint, see the article on absorption and exhaustion.

What the order book is still good for

  • Judging current market depth - how far a market order would actually move price, which bears directly on expected execution cost
  • Spotting thin areas where price tends to travel faster
  • Alerting on conspicuous changes as a prompt for a human look rather than as an automatic trigger
  • Checking your own orders: where yours sits relative to the rest and whether it is realistically going to be reached

For why market depth feeds straight into the fill price, see the article on slippage in a trading bot.

Frequently Asked Questions

Can a bot react to order book data at all?

Technically yes - the data is there live and reacting to it is perfectly feasible. The limitation isn't the reaction, it's the verification beforehand: without a historical book state, there's no basis for testing the rule over a longer period.

What is spoofing, and does a bot need to account for it?

Spoofing means placing orders with no intention of having them filled. It is prohibited on regulated exchanges, but from the outside it can't be reliably distinguished from a legitimately cancelled order. In practice the takeaway is simpler: a rule shouldn't depend on a resting order staying put.

Is combining the order book with the footprint the better route?

Usually yes, because the confirmation then comes from executed data. The part of the rule that rests on executions also stays testable - and that's the part you can actually make a statement about.

How much storage does your own order book history need?

That depends entirely on how many price levels and what update rate you store - there are orders of magnitude between a lean recording of a few metrics and a complete capture. Which is why it pays to decide up front which values the rule genuinely needs.

The order book isn't a worse tool than the footprint, it simply answers a different question - and one whose answer can be withdrawn at any moment. Accounting for that while designing an automated rule saves the disappointment of a signal that convinces live but can never be verified afterwards.

Have an idea for ATAS?

Tell us about your project - you'll get a free, non-binding quote within 24-48 hours.

Request a Free Quote