Order-Book Depth Units for Autonomous Trading Agents
By DX Research Group · · Market data
A three-level example showing how depth differs from a best quote and why aggregation matters.
A trading agent evaluating a proposed quantity needs more than the inside quote. We work through a frozen synthetic book to show what a depth feature can measure and where an execution assumption begins.
Order-book depth is a statement about displayed quantities at specified prices. A best bid and ask describe only the inside market. Deeper levels supply the quantities a larger hypothetical order would encounter.
Calculate a bounded example
Assume a synthetic ask book with one unit at 100, two units at 101, and three units at 102. Displayed base quantity through 102 is six units. Displayed quote notional is 1 × 100 + 2 × 101 + 3 × 102 = 608. These are different measurements and should have different column names.
A hypothetical three-unit sweep of this frozen book consumes one unit at 100 and two at 101, for a total of 302 and a volume-weighted price of 100.6667, rounded here for display. That is a calculation on the snapshot. Realized fills require separate evidence because the book can change before an order arrives.
Coinbase's book reference distinguishes top-of-book, aggregated, and nonaggregated levels. It explicitly notes that an aggregated size already sums orders at that price. Multiplying that size by the number of orders would count the quantity again.
Define the depth window
Depth through a fixed price and depth within a percentage of the midpoint answer different questions. State the reference price, side, inclusion boundary, and unit. For example, ask notional within one percent of a midpoint of 100 includes levels no greater than 101 under an inclusive rule. The synthetic 102 level is outside that window.
When comparing instruments, a fixed number of levels may cover very different price distances. Keep both the level count and covered distance visible. A feed that supplies only one level supports only inside-market measurements.
Validate the snapshot before arithmetic
Check that asks ascend, bids descend, prices are positive, and sizes are nonnegative under the venue's message semantics. Distinguish a snapshot from incremental updates. An update with size zero may remove a level rather than contribute a zero-sized persistent order, depending on the protocol.
Retain the source sequence and capture time. If reconstruction has a known gap, quarantine the derived depth until recovery succeeds. Confirm update coverage independently of numeric plausibility.
A reusable fixture
The three ask levels provide expected totals of six base units and 608 quote units. Add a count-of-orders field to the aggregated fixture and confirm the totals remain identical. Then request a quantity of seven units. The calculation should report insufficient displayed depth rather than extrapolating the last price.
Limits of displayed depth
Displayed orders may be canceled or consumed, and some liquidity may not appear in the snapshot. Fees, latency, queue position, and order rules are separate concerns. A depth calculation is useful when its boundaries are explicit: this much displayed quantity was present in this captured book, under these parsing rules. Keep that observation distinct from realized execution.
Place this check in the agent loop
Our state and memory framework explains how this input contract fits a persistent trading agent. Use the harness-transfer test design to distinguish a data-adapter change from a change in model behavior.