imbalance_5Imbalance (5 levels)
Imbalance across five levels extends top-of-book pressure into the near-touch order book.
It reveals whether directional support is just a quote-level artifact or is backed by additional nearby depth.
Shown: net taker flow (buys minus sells) summed over each venue’s perpetuals, per minute, 18:00–01:00 UTC on 10 Oct 2025, buys above each venue’s line and sells below it on a square-root scale; the deepest sell minute, 21:13 UTC with $1.9B net sold across the three venues, is orange · built with flow 1m
We define Directional Alpha as a signal that exhibits a consistent positive or negative relationship with forward returns.
Or have your agent rerun this notebook and tell you what it finds. Start in ClaudeClaude CodeCodexSee the prompt
01
02
03
Metrics in this use case
This notebook introduces order-flow analytics with the `aperiodic` Python package. We focus on a single large-cap instrument — Binance BTC perpetuals (`perpetual-BTC-USDT:USDT`) — over the exact six-month window from September 1, 2025 through February 28, 2026, using 1-hour observations.
View notebookFrom raw order flow to a ranked, backtestable signal — every step in runnable code.
Shown: minute lows of the 465 Binance perpetuals, 20:40–22:00 UTC on 10 Oct 2025, with BTC’s path traced · built with ohlcv 1m
L2 (Order Book)
Multi-depth (5, 10, 20, 25 levels) order book imbalance, ratio, and averages.
Raw L2 isn't offered yet. Ask us.
Shown: imbalance_20, imbalance_10, imbalance_5, daily, 1–31 January 2024, from this page's Sample CSV · extreme: −56.931, 14 Jan, imbalance_10 · built with l2_imbalance
imbalance_5Imbalance across five levels extends top-of-book pressure into the near-touch order book.
It reveals whether directional support is just a quote-level artifact or is backed by additional nearby depth.
imbalance_ratio_25The twenty-five-level imbalance ratio normalizes deep-book pressure over a broader slice of resting liquidity.
It is useful for understanding the full displayed environment that larger orders would have to push through.
bid_ask_ratio_25The twenty-five-level ratio extends that comparison deep enough to capture broader displayed inventory.
It is especially relevant for larger execution and for understanding whether apparent pressure near the touch is reinforced deeper in the ladder.
/api/v1/data/l2_imbalance| Field | Name | Description |
|---|---|---|
imbalance_5 | Imbalance (5 levels) | Last top-5 bid quantity minus top-5 ask quantity |
imbalance_10 | Imbalance (10 levels) | Last top-10 bid quantity minus top-10 ask quantity |
imbalance_20 | Imbalance (20 levels) | Last top-20 bid quantity minus top-20 ask quantity |
imbalance_25 | Imbalance (25 levels) | Last top-25 bid quantity minus top-25 ask quantity |
imbalance_ratio_5 | Imbalance Ratio (5 levels) | Last normalized difference between top-5 bid and ask quantity |
imbalance_ratio_10 | Imbalance Ratio (10 levels) | Last normalized difference between top-10 bid and ask quantity |
imbalance_ratio_20 | Imbalance Ratio (20 levels) | Last normalized difference between top-20 bid and ask quantity |
imbalance_ratio_25 | Imbalance Ratio (25 levels) | Last normalized difference between top-25 bid and ask quantity |
bid_ask_ratio_5 | Bid/Ask Ratio (5 levels) | Last top-5 bid quantity divided by top-5 ask quantity |
bid_ask_ratio_10 | Bid/Ask Ratio (10 levels) | Last top-10 bid quantity divided by top-10 ask quantity |
bid_ask_ratio_20 | Bid/Ask Ratio (20 levels) | Last top-20 bid quantity divided by top-20 ask quantity |
bid_ask_ratio_25 | Bid/Ask Ratio (25 levels) | Last top-25 bid quantity divided by top-25 ask quantity |
imbalance_5_avg | Avg Imbalance (5 levels) | Average top-5 bid quantity minus top-5 ask quantity in the interval |
imbalance_10_avg | Avg Imbalance (10 levels) | Average top-10 bid quantity minus top-10 ask quantity in the interval |
imbalance_20_avg | Avg Imbalance (20 levels) | Average top-20 bid quantity minus top-20 ask quantity in the interval |
imbalance_25_avg | Avg Imbalance (25 levels) | Average top-25 bid quantity minus top-25 ask quantity in the interval |
imbalance_ratio_5_avg | Avg Imbalance Ratio (5 levels) | Average normalized difference between top-5 bid and ask quantity in the interval |
imbalance_ratio_10_avg | Avg Imbalance Ratio (10 levels) | Average normalized difference between top-10 bid and ask quantity in the interval |
imbalance_ratio_20_avg | Avg Imbalance Ratio (20 levels) | Average normalized difference between top-20 bid and ask quantity in the interval |
imbalance_ratio_25_avg | Avg Imbalance Ratio (25 levels) | Average normalized difference between top-25 bid and ask quantity in the interval |
bid_ask_ratio_5_avg | Avg Bid/Ask Ratio (5 levels) | Average top-5 bid quantity divided by top-5 ask quantity in the interval |
bid_ask_ratio_10_avg | Avg Bid/Ask Ratio (10 levels) | Average top-10 bid quantity divided by top-10 ask quantity in the interval |
bid_ask_ratio_20_avg | Avg Bid/Ask Ratio (20 levels) | Average top-20 bid quantity divided by top-20 ask quantity in the interval |
bid_ask_ratio_25_avg | Avg Bid/Ask Ratio (25 levels) | Average top-25 bid quantity divided by top-25 ask quantity in the interval |
# 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_imbalance --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"Every new row as it is computed, over WebSocket at wss://stream.aperiodic.io/v1/stream. Authenticate with your API key in the X-API-KEY header and subscribe to channels named l2_imbalance.<exchange>.<interval>, on intervals 15s, 30s, 1m, 5m, 15m, 30m, 1h, 4h, 1d (15s and 30s on Institutional Live only). Streaming is included on Live plans.
pip install "aperiodic[stream]"import os
from aperiodic import stream
for message in stream(
api_key=os.environ["APERIODIC_API_KEY"],
dataset="l2_imbalance",
exchange="binance-futures",
interval="1m",
symbols=["perpetual-BTC-USDT:USDT"], # omit for every symbol on your plan
):
print(message.channel, message.snapshot, message.data)timestampreqstringTimestamp source. 'exchange' uses the exchange-reported timestamp, 'true' uses actual arrival time at our servers.
exchangetrueintervalreqstringAggregation time interval for the data. Sub-minute intervals (15s, 30s) require an Institutional plan.
15s30s1m5m15m30m1h4h1dexchangereqstringSource exchange for the data.
binance-futuresokx-perpshyperliquid-perpssymbolreqstringTrading pair symbol in the format of Atlas' universal symbology: https://github.com/aperiodic-io/atlas
start_datereqstring<date>Start date for the data range (YYYY-MM-DD format). A metric series starts on the first day of the raw series it is computed from (see /metadata/raw); raw trades and quotes start binance-futures from 2020-01-01, okx-perps from 2019-09-01, hyperliquid-perps from 2025-01-01. Earlier days return no files. How far back you can go depends on the plan: 5 years on Pro, full history on Prime, Prime + Raw and Institutional. An earlier start_date than the plan reaches returns 403.
end_datereqstring<date>End date for the data range (YYYY-MM-DD format). Must be greater than or equal to start_date.
Successful response with download URLs for every existing file covering the range from the series' published start — one per month before 2026-08-01, one per day from 2026-08-01 onwards
filesobject[]requiredFiles covering the requested date range, in chronological order. Data before 2026-08-01 is split by month (one file per calendar month, no `day`); data from 2026-08-01 onwards is split by day (one file per calendar day, with `day` set). The changeover falls on a month boundary, so a given month is served entirely one way or the other; a range spanning it returns the earlier months as monthly files followed by a daily file per day.
yearintegerrequiredYear of the data file
monthintegerrequiredMonth of the data file (1-12)
dayintegerDay of the data file (1-31). Present only on daily files, i.e. those covering 2026-08-01 onwards. Absent on monthly files, which cover an entire calendar month.
urlstring<uri>requiredPresigned URL for direct file download (valid for 5 minutes). URLs are served from dataset-specific subdomains, e.g. ohlcv.aperiodic.io, trade-metrics.aperiodic.io, l1-metrics.aperiodic.io, l2-metrics.aperiodic.io, derivative-metrics.aperiodic.io.
{
"files": [
{
"year": 2026,
"month": 6,
"url": "https://ohlcv.aperiodic.io/binance-futures/1h/BTCUSDT/2026-06.parquet?X-Amz-Expires=300&..."
},
{
"year": 2026,
"month": 7,
"url": "https://ohlcv.aperiodic.io/binance-futures/1h/BTCUSDT/2026-07.parquet?X-Amz-Expires=300&..."
},
{
"year": 2026,
"month": 8,
"day": 1,
"url": "https://ohlcv.aperiodic.io/binance-futures/1h/BTCUSDT/2026-08-01.parquet?X-Amz-Expires=300&..."
},
{
"year": 2026,
"month": 8,
"day": 2,
"url": "https://ohlcv.aperiodic.io/binance-futures/1h/BTCUSDT/2026-08-02.parquet?X-Amz-Expires=300&..."
}
]
}
Prefilled with the shared DEMO-KEY and a free preview slice — send the request to see live data, no account required.
/api/v1/data/preview/l2_imbalance?timestamp=exchange&interval=5m&exchange=binance-futures&symbol=perpetual-BTC-USDT%3AUSDT&start_date=2025-05-01&end_date=2025-05-31