Estimating execution VWAP from a saved order book

By DX Research Group · · Execution mechanics

Walk book levels to calculate an illustrative execution estimate while preserving its snapshot limitations.

Two different meanings of VWAP

We walk a small saved ladder here to expose the assumptions behind an execution estimate.

A volume-weighted average execution price is total executed value divided by executed quantity. A market VWAP benchmark can instead summarize trades over a time window. An autonomous agent's evaluator needs to identify which quantity it means. Comparing a snapshot estimate with a later market benchmark answers a different question from reconstructing actual fills.

This note concerns the first meaning: a size-weighted estimate from a saved order book. Coinbase documents price-time matching against resting prices. That venue rule is a useful grounding example, but the arithmetic below is an illustrative estimator rather than a reconstruction of its matching engine.

Walk an illustrative ask ladder

Suppose the visible asks contain two units at 100, three at 101, and five at 103. An agent intends to purchase six units. Consume the two units at the first level, three at the second, and one at the third. Estimated gross spend is 200 + 303 + 103 = 606. Estimated execution VWAP is 606 / 6 = 101.

The worst consumed price is 103. That matters independently of the average: a buy limit of 102 would exclude the last level. Under the simplified book assumption, only five units are available within that limit, costing 503 and averaging 100.6. Reporting a six-unit average of 101 under that same limit would be internally inconsistent.

All values here are illustrative. They are not current market data, a trading recommendation, or a measured DXRG execution result.

A procedure with a useful failure result

Sort asks from lowest to highest for buys, or bids from highest to lowest for sells. Verify that prices and quantities use the expected instrument units. Apply the allowed price boundary before accumulating value. At each eligible level, take the smaller of remaining desired quantity and visible level quantity. Stop when the desired quantity is exhausted or eligible depth ends.

Return filled quantity, unfilled quantity, total value, average price, and worst consumed price. If depth is insufficient, preserve that result. Extrapolating the last observed price silently turns missing evidence into invented liquidity. A partial estimate can still be useful if its coverage is explicit.

Fees require a separate assumption or actual receipt. They do not belong in a gross VWAP field. Contract multipliers also change the relation between quoted quantity and economic notional. A spot unit, linear derivative quantity, and inverse contract count cannot be merged by treating each as the same base amount.

Test the estimator against evidence

A fixture can contain the three levels above and assert both the unrestricted six-unit case and the five-unit price-limited case. Additional cases include zero desired size, no eligible levels, duplicate levels, malformed quantities, and a book timestamp older than the declared freshness allowance.

Visible depth can change before arrival. Other orders can consume it, hidden orders may interact, and venue protections can constrain market orders. Therefore, save the snapshot time and the instruction time alongside the estimate. Later compare the actual execution average with this recorded estimate, explaining differences rather than retroactively changing inputs.

The result is a small, inspectable execution calculation. It provides no evidence that an agent's forecasts or portfolio decisions improve.

Fit the receipt into the full trace

Our execution and settlement framework connects these mechanics to recorded outcomes. The operating-layer controls paper explains why the machinery around an agent deserves its own evaluation.

Sources

Related field notes