Order book
A BTC-USD book from 14 sequenced deltas, printed as a depth ladder with spread, micro-price, imbalance and the VWAP of a 5 BTC market buy. Then a crossing delta is rejected and rolled back, and a sequence gap is refused.
cargo run --example order_bookBTC-USD level-2 book, top 7 levels, seq 14 side price size cum depth ask 64,256.00 4.900 14.129 ask 64,254.50 1.125 9.229 ask 64,253.00 3.460 8.104 ask 64,252.00 2.077 4.644 ask 64,251.50 0.415 2.567 ask 64,251.00 1.310 2.152 ask 64,250.50 0.842 0.842 ---- spread 0.50 (0.08 bps) mid 64,250.25 ---- bid 64,250.00 1.204 1.204 bid 64,249.50 0.655 1.859 bid 64,249.00 2.380 4.239 bid 64,248.00 1.720 5.959 bid 64,247.50 3.015 8.974 bid 64,246.00 2.260 11.234 bid 64,244.50 5.400 16.634 mid 64,250.25 (best bid + best ask) / 2 micro-price 64,250.29 size-weighted mid imbalance +0.081 bid-heavy buy 5 BTC 64,251.52 VWAP walking the asks, 0.20 bps over mid seq 15 bid 64,251.00 x 2.0 rejected Inverted spread: best_bid 64251.00 >= best_ask 64250.50 book unchanged rolled back best bid still 64,250.00, seq still 14 seq 17 ask 64,250.50 x 0.5 rejected Order book sequence mismatch: expected 15, got 17