Metrics library · L1 & L2 order book
Depth within 10 levels, both sides, BTC perps, last 24 hours
DELAYED 15 MIN…Updates by itself every 5 minutes
Depth within 10 levels, both sides, latest
In dollars, so the venues compare directly.
The size resting behind the best quote, 5 to 25 levels deep.
Total bid/ask depth aggregated over 5, 10, 20, 25 order book levels — instantaneous and interval-averaged.
The 5m bar from 14:00 to 14:05 UTC on 14 May 2025, Binance BTC-USDT perpetual, from the free preview.
Step 1
bid_agg_N is the BTC resting on the top N bid levels, and ask_agg_N the same for asks, so each one grows with N.
Step 2
The difference between consecutive depths is the size in that band. On this book, over 90% of the size within 25 levels is in the top five.
Step 3
On average through the bar, the asks held about twice the size they held at the close. Each snapshot counts once.
Step 4
BTC-USDT perpetual on Binance, 5m bars, 1 to 31 May 2025, from the free preview.
Median BTC resting within each depth, averaged over the bar. BTC.
Median depth, averaged through each bar: 19.2 BTC at the touch, 20.3 BTC within 5 levels and 25.8 BTC within 25, about $2.7M. Bids and asks were close to symmetric.
With a quote on every tick, 25 levels on this book span 0.24 bps of price. A trade larger than the best quote fills against much thinner levels behind it.
DELAYED 15 MINto 14:45 UTCUpdates by itself every 5 minutes
Highest
Lowest
bid_agg_N and ask_agg_N are the base-asset size within the top N levels of each side: 5, 10, 20 or 25. Multiply by price for dollars.
The _avg fields are the mean over every book snapshot in the interval. The plain fields are the last one. Prefer the average, since one snapshot can catch quotes mid-refresh.
A level is a price step, so the same number of levels covers different distances on different contracts. Compare contracts in dollars and bps, not in levels.
Top-of-book metrics capture only the frontier of the limit order book. The deeper levels — where the bulk of resting liquidity sits — tell you about market resilience: the ability to absorb large orders without significant price displacement.
Biais, Hillion & Spatt (1995) conducted one of the earliest empirical analyses of the full limit order book (on the Paris Bourse), demonstrating that the shape of the book — not just the top level — contains predictive information about future price dynamics. They showed that the distribution of depth across price levels reveals the strategic behavior of limit order traders, who place orders deeper in the book during periods of uncertainty and closer to the market when they want to trade.
Gould et al. (2013) provided a comprehensive review of the limit order book literature, establishing that book depth at multiple levels is a key state variable for models of price formation. Markets with deep, evenly distributed books are resilient — they can absorb large trades with minimal price impact. Markets with concentration at the top and sparse deeper levels are fragile.
We track order book state at four cumulative depth tiers: 5, 10, 20, and 25 price levels per side.
How stable is the total depth over an interval? If depth is stable, market makers are committed — they're not pulling quotes defensively. High depth volatility means liquidity providers are repricing rapidly, which Foucault, Kadan & Kandel (2005) modeled as the optimal response to changing information asymmetry: when adverse selection risk rises, limit order traders either cancel or reprice their quotes.
Depth volatility spikes often precede or accompany large directional moves. The mechanism: market makers detect toxic flow (through their own monitoring of order flow patterns) and begin pulling quotes before the move becomes visible in prices. The L2 depth drain is the leading indicator; the price move is the lagging consequence.
The most actionable signal from L2 data is its divergence from L1:
References:
# Install the Aperiodic CLI into ~/.local/bin
mkdir -p "$HOME/.local/bin"
curl -fsSL https://raw.githubusercontent.com/aperiodic-io/cli/main/install.sh | INSTALL_DIR="$HOME/.local/bin" bash
export PATH="$HOME/.local/bin:$PATH"
# Free preview — no API key required
aperiodic l2_liquidity --preview \
--exchange binance-futures \
--symbol perpetual-BTC-USDT:USDT \
--interval 5m \
--timestamp exchange \
--start-date 2025-05-01 \
--end-date 2025-05-31 \
--output-dir ./data && echo "Saved to $PWD/data"