Skip to content
datastore.sh

Crypto Order Book Data: L2 Snapshots, Depth and Order Flow From On-Chain Venues

What crypto order book data actually contains, how snapshots differ from incremental updates and order events, and how to measure spread, depth and imbalance from Hyperliquid L2 snapshots and Solana order-book programs without fooling yourself.

Data Platform15 min read

Crypto order book data is the record of resting buy and sell orders on a trading venue: at each price level, how much size is offered, and on some venues how many orders make it up. Historical order book data stores that state over time, either as periodic snapshots of the book, as a stream of incremental updates, or as the individual order events that change it. It is the input for spread, depth, liquidity and market-impact research, and for any backtest that needs to know what a trade would have cost rather than only what price printed.

Most order book data comes from centralized exchanges, captured from their WebSocket feeds by vendors. On-chain venues are different: Hyperliquid's fully on-chain book produces snapshots that can be archived, while Solana's order-book programs, Phoenix and OpenBook, record every order placement and cancellation as an instruction. Those sources answer different questions, and confusing them is the most common way order book research goes wrong.

This guide covers what each form of order book data contains, and how to compute spread, depth and imbalance from Hyperliquid historical data with queries that run as written. Every claim about the datastore.sh tables is checked against the published schemas and free sample files.

What Is Crypto Order Book Data?

An order book is the set of limit orders waiting to trade. Bids are orders to buy, asks are orders to sell, and the gap between the best bid and the best ask is the spread. Order book data comes in three levels of detail.

LevelWhat it recordsWhat it answersWhat it cannot answer
L1 (top of book)Best bid and best ask, with their sizesSpread, mid price, quoted size at the touchHow much size sits behind the touch
L2 (market by price)Total size at each price level, often with an order countDepth, slippage for a given size, book imbalanceWhich orders make up a level, or queue position
L3 (market by order)Every individual order with its ID, price and sizeQueue position, order lifetimes, cancellation behaviorNothing about the book is aggregated away

L2 is the research workhorse: detailed enough to estimate what a market order would have paid, compact enough to store for months. L3 is what queue modeling needs, but few venues publish it historically.

Snapshots, incremental updates and order events

Separate from the level of detail is the form the history takes, and each form fails differently.

FormWhat a record isStrengthFailure mode
SnapshotsThe full visible book at a momentEach record is self-contained; no reconstruction neededAnything that happens between snapshots is invisible
Incremental updates (deltas)A change to one price levelCaptures every change the feed reportedOne missed message corrupts the rebuilt book until the next resync
Order eventsOne order placed, cancelled, modified or filledThe most granular; supports L3 analysisYou must replay the matching rules to know the book state

Commercial vendors for centralized exchanges typically sell incremental updates plus snapshots reconstructed from them. Tardis.dev, for example, publishes tick-level incremental_book_L2 alongside pre-built top-25 and top-5 level snapshots. On-chain venues expose different raw material, covered next.

Where On-Chain Order Book Data Comes From

On a centralized exchange, the feed is the only window into the book. On a chain, the matching engine's inputs, and on some venues its state, are part of a public ledger, so the history can be checked independently.

Not every on-chain venue has a book. Most Solana DEX volume runs through automated market makers, whose pools have reserves and liquidity bins rather than bids and asks (see our Solana DEX historical data guide). Order book data on Solana means the central limit order book (CLOB) programs, chiefly Phoenix and OpenBook. Their books live in account state, while the ledger records the instructions that change them.

The practical consequence: Hyperliquid gives you L2 book snapshots. Solana CLOBs give you order flow. Both are order book data, they are not interchangeable, and the rest of this guide treats them separately.

Hyperliquid Order Book Data: What a Snapshot Contains

Hyperliquid runs a fully on-chain central limit order book for perpetuals and spot. There are three official routes to its book data, plus prepared datasets.

The live API. The l2Book request returns the current book for one coin, up to 20 levels per side, with an optional nSigFigs parameter that rounds prices into wider levels (Chainstack reference). It is current state, not history.

The public S3 archive. Hyperliquid's historical data documentation lists L2 snapshots under s3://hyperliquid-archive/market_data/[date]/[hour]/[datatype]/[coin].lz4, uploaded approximately once a month with no guarantee of timeliness or completeness. The bucket is requester-pays, and decompressing, parsing and validating is yours to do; see where Hyperliquid historical data comes from.

A node gives you raw book differences and order statuses from today forward, not the past.

A prepared dataset. The Hyperliquid Historical dataset includes an l2_order_book_snapshots table delivered as typed Parquet. One row is one snapshot of one coin's book:

ColumnTypeMeaning
exchange_timetimestamp, msWhen the exchange produced the snapshot. Use this for market analysis.
receipt_timetimestamp, nsWhen the snapshot was received. The gap to exchange_time is capture latency, not market behavior.
coinstringHyperliquid market symbol
bid_px, bid_sz, bid_narraysPrice, size and order count per bid level, best first
ask_px, ask_sz, ask_narraysThe same for asks
ver_numintegerSnapshot format version
source_day, source_hour, ingested_atprovenanceWhere the row came from, not when the market moved

The levels are stored as parallel arrays rather than one row per level. Index 1 (in DuckDB's 1-based indexing) is the top of the book on both sides, so most measures need no unnesting. The _n arrays carry the number of resting orders at each level, which is the closest an L2 snapshot gets to L3 information. A level of 30 BTC from 2 orders is a different market from 30 BTC across 40.

What the free sample shows is worth stating precisely, because it sets the limits of every measure below. The published 100-row sample for this table is BTC on May 1, 2026:

  • 20 levels per side in every row, matching the API's level limit.
  • About 540 ms between snapshots (median 539 ms; 483 to 625 ms across the sample).
  • A one-tick spread. BTC levels are $1 apart, so the touch sits at about 0.13 basis points.
  • A shallow visible window. With $1 levels, 20 levels reach only 2.5 to 3 basis points from the mid on the shallower side.

That last point matters most. It means the snapshot shows the inside of the BTC book in fine detail, and nothing beyond about 3 bps. A "depth within 10 bps" measure computed from these rows would silently report only the first 3 bps of it.

Coverage is narrower than the rest of the dataset. The dataset's listed coverage is July 2025 to July 2026, and the fills in the swaps table span all of it, but the snapshot table spans May to June 2026 (about 37 million rows). If your study needs the book alongside the trades, your usable window is the book's window. The table-by-table guide lists each table's range.

This also decides which coverage window to buy. The dataset is sold per window, and every window includes all nine tables. As of November 2026 the windows are the latest month ($200), the last 6 months ($500), the last 12 months ($1,000) and the full history ($2,000), each counted back from the end of the listed history. Because the order-book table ends in June 2026, the latest-month window holds little or none of it. For order-book work, choose the 6-month window or longer. The free sample bundle (100 rows of every table) is the way to check the schema before buying.

Measuring Spread, Depth and Imbalance

The queries below run as written in DuckDB and were checked against the sample. One type detail: prices and sizes are stored as exact Decimal(38,18), and multiplying two of them overflows. Cast to DOUBLE first, as the book CTEs below do.

Spread in basis points

Absolute spread is meaningless across coins with different prices. Express it relative to the mid.

sql
-- Average top-of-book spread per minute, in basis points of mid.
SELECT date_trunc('minute', exchange_time) AS minute,
       coin,
       avg((ask_px[1] - bid_px[1])
           / ((ask_px[1] + bid_px[1]) / 2) * 1e4) AS spread_bps,
       count(*)                                     AS snapshots
FROM read_parquet('hyperliquid/historical/l2_order_book_snapshots/schema=v1.0/date=*/part-*.parquet')
WHERE coin = 'BTC'
GROUP BY 1, 2
ORDER BY 1;

Keep the snapshots count: a minute averaged over 3 snapshots is a gap, not a measurement.

Depth, but only as deep as the book is visible

Depth is the notional you could trade before moving the price by a given amount. With a 20-level snapshot, compute how far the book reaches first, and only report a depth band the snapshot actually covers.

sql
WITH book AS (
  SELECT exchange_time, coin,
         CAST(bid_px AS DOUBLE[]) AS bp, CAST(bid_sz AS DOUBLE[]) AS bs,
         CAST(ask_px AS DOUBLE[]) AS ap, CAST(ask_sz AS DOUBLE[]) AS az
  FROM read_parquet('hyperliquid/historical/l2_order_book_snapshots/schema=v1.0/date=*/part-*.parquet')
  WHERE coin = 'BTC'
), m AS (
  SELECT *, (bp[1] + ap[1]) / 2 AS mid FROM book
)
SELECT exchange_time,
       mid,
       -- how far from mid the visible book reaches, on its shallower side
       least(mid - bp[-1], ap[-1] - mid) / mid * 1e4 AS reach_bps,
       -- notional within 2 bps of mid, only where the snapshot reaches 2 bps
       CASE WHEN least(mid - bp[-1], ap[-1] - mid) / mid * 1e4 >= 2 THEN
         list_sum([x[1] * x[2] FOR x IN list_zip(bp, bs) IF x[1] >= mid * (1 - 0.0002)])
       END AS bid_usd_2bps,
       CASE WHEN least(mid - bp[-1], ap[-1] - mid) / mid * 1e4 >= 2 THEN
         list_sum([x[1] * x[2] FOR x IN list_zip(ap, az) IF x[1] <= mid * (1 + 0.0002)])
       END AS ask_usd_2bps
FROM m
ORDER BY exchange_time;

bp[-1] is the deepest visible bid. When the band you ask for is wider than reach_bps, the query returns NULL rather than a number that looks like depth and is really a truncation. On the sample, BTC notional inside 2 bps ranges from about $0.3 million to $16 million per side within a single minute, which is itself a finding: depth at the touch is far more volatile than spread, which barely moves. Smaller coins with coarser ticks reach much further from the mid in 20 levels, so the same band can be valid for one market and invalid for another. Check reach per coin.

Imbalance and the weighted mid

Book imbalance compares resting size on the two sides, and is one of the most studied short-horizon signals in microstructure. Cont, Kukanov and Stoikov found that over short intervals, price changes are mainly driven by order flow imbalance at the best bid and ask. Stoikov's later micro-price adjusts the mid using top-of-book imbalance and spread.

sql
WITH book AS (
  SELECT exchange_time, coin,
         CAST(bid_px AS DOUBLE[]) AS bp, CAST(bid_sz AS DOUBLE[]) AS bs,
         CAST(ask_px AS DOUBLE[]) AS ap, CAST(ask_sz AS DOUBLE[]) AS az
  FROM read_parquet('hyperliquid/historical/l2_order_book_snapshots/schema=v1.0/date=*/part-*.parquet')
  WHERE coin = 'BTC'
)
SELECT exchange_time,
       (bp[1] + ap[1]) / 2                                AS mid,
       bs[1] / (bs[1] + az[1])                            AS top_imbalance,
       (bp[1] * az[1] + ap[1] * bs[1]) / (bs[1] + az[1])  AS weighted_mid,
       list_sum(bs[1:5]) / (list_sum(bs[1:5]) + list_sum(az[1:5])) AS imbalance_5
FROM book
ORDER BY exchange_time;

top_imbalance runs from 0 (all size on the ask) to 1 (all on the bid). The weighted mid leans toward the side with less size, because that side is closer to being consumed. In the sample, top imbalance goes from 0.41 to 0.32 to 0.99 across three consecutive snapshots, about 1.1 seconds, while the mid stays at 76,331.5. That is normal for a one-tick market and is why imbalance is studied as a leading signal, not a description of price.

Touch imbalance is noisy, so deeper measures like imbalance_5 are often steadier. And a 540 ms interval samples the signal rather than observing every change; studies of how imbalance changes need event data.

Joining the Book to Trades

Order book data becomes far more useful next to the fills. The question "what was the spread when this trade happened?" needs an as-of join: for each trade, the most recent snapshot at or before it.

sql
WITH book AS (
  SELECT exchange_time, coin,
         CAST(bid_px AS DOUBLE[]) AS bp, CAST(ask_px AS DOUBLE[]) AS ap
  FROM read_parquet('hyperliquid/historical/l2_order_book_snapshots/schema=v1.0/date=*/part-*.parquet')
)
SELECT s.block_time, s.coin, s.px, s.sz, s.direction, s.liquidity_role,
       b.exchange_time                               AS book_time,
       (b.bp[1] + b.ap[1]) / 2                       AS mid_before,
       epoch_ms(s.block_time) - epoch_ms(b.exchange_time) AS book_age_ms
FROM read_parquet('hyperliquid/historical/swaps/schema=v1.0/date=*/part-*.parquet') s
ASOF JOIN book b
  ON s.coin = b.coin AND s.block_time >= b.exchange_time
WHERE s.block_time >= TIMESTAMP '2026-05-01'
  AND s.block_time <  TIMESTAMP '2026-07-01';

Effective spread is how far the fill sits from mid_before; a markout compares the fill to the mid some seconds later. Keep book_age_ms: a trade matched to a 500 ms old snapshot is measured against a book that may have moved, and filtering on book age bounds that error. The date filter keeps the join inside the book's coverage window. Fills also carry liquidity_role and a liquidation flag, so forced liquidations can be separated from discretionary flow before estimating impact.

Solana Order Books: Phoenix and OpenBook Order Flow

Solana's two main central limit order book programs keep their books in on-chain accounts. The ledger records the instructions that change those books. That gives a different kind of order book data: not what the book looked like, but what every participant asked it to do.

What the tables contain

OpenBook V2 tables include place-order, place-take-order, cancel-order, cancel-all-orders, consume-events and create-market, plus a market-meta-data-log-event table. A decoded place-order row carries its arguments as JSON:

json
{
  "side": "Ask",
  "order_type": "Limit",
  "price_lots": 355,
  "max_base_lots": 1000000,
  "max_quote_lots_including_fees": 999999999999,
  "client_order_id": 853573831,
  "expiry_timestamp": 0,
  "self_trade_behavior": "DecrementTake",
  "limit": 255
}

Phoenix V1 tables include place-limit-order, place-multiple-post-only-orders, swap, the cancel family (cancel-up-to, cancel-multiple-orders-by-id, cancel-all-orders) and initialize-market. A place-limit-order row carries an order packet:

json
{
  "Limit": {
    "side": "Ask",
    "price_in_ticks": 112739,
    "num_base_lots": 5000,
    "client_order_id": 73223,
    "self_trade_behavior": "CancelProvide",
    "match_limit": null,
    "last_valid_slot": null
  }
}

Every row also carries the slot, transaction index, instruction path and signature, so the order of events within a block is preserved exactly.

Converting lots and ticks to prices

Neither program stores human-readable prices; prices and sizes are integers in market-specific units.

For OpenBook, the market's lot sizes and token decimals are in market-meta-data-log-event (base_lot_size, quote_lot_size, base_decimals, quote_decimals). The conversion is:

text
native_price = price_lots × quote_lot_size / base_lot_size
ui_price     = native_price × 10^(base_decimals − quote_decimals)
base_qty     = max_base_lots × base_lot_size / 10^base_decimals

For Phoenix, prices are in ticks and sizes in base lots, using parameters fixed when the market was created. Those are recorded in the initialize_params of the market's initialize-market row. Join each order to its market's parameters before converting; a unit error is off by powers of ten.

What order flow answers, and what it does not

Order flow supports research snapshots cannot: how often makers re-quote and how far from the touch, order-to-cancel ratios per market or signer, the mix of post-only, immediate-or-cancel and limit orders, and which accounts supply most resting liquidity.

What the tables do not contain matters as much. They do not contain fills or book state. On OpenBook, matching writes fills to the market's event heap, an account, and the consume-events instruction records only that the crank ran. On Phoenix, market events go through a log instruction whose payload is not decoded into columns in the current tables. So neither program's tables can, alone, say which orders traded or rebuild an L2 book; that needs account-state history or decoded fill events. A placement is not resting liquidity.

That split is the key choice. For depth and spread over time, use L2 snapshots, as Hyperliquid provides. For who quoted what and how, use the Solana CLOB order flow.

Order Book Data Pitfalls: A Validation Checklist

Before trusting any measure built from order book data, check each of these.

  1. Visible reach. Compute how far a 20-level snapshot reaches per coin, and never report a wider depth band.
  2. Cadence and gaps. Count snapshots per minute and find the longest gap per hour. A 30-second hole in a 500 ms series is not a quiet market.
  3. Exchange versus receipt time. Measure the market with exchange_time; use receipt_time only for capture latency.
  4. Crossed or locked books. bid_px[1] >= ask_px[1] is a capture problem, not an arbitrage. The sample has none; test your full window.
  5. Aggregated levels. If prices were rounded (as with nSigFigs), levels are buckets and spread is overstated. Check level spacing against the tick.
  6. Coverage mismatch. Restrict book-to-trade joins to the window both cover.
  7. Units and types. Cast exact decimals before multiplying, and convert Solana lots and ticks through each market's own parameters.
  8. Orders are not liquidity. A placement can be cancelled in the same slot or matched at once. Do not count placements as depth.

Choosing a Source of Crypto Order Book Data

SourceFormVenuesBest forWatch for
CEX data vendorsIncremental L2 and rebuilt snapshotsCentralized exchangesCross-exchange CEX microstructureFeed gaps, vendor rebuild rules, licensing
Hyperliquid APILive L2, up to 20 levelsHyperliquidCurrent state, recording going forwardNot a history; rate limits
Hyperliquid S3 archiveHourly L2 snapshot filesHyperliquidRaw history if you build the pipelineMonthly uploads, possible gaps, requester-pays
Your own nodeRaw book diffs and order statusesHyperliquidFull control from today onwardNo backfill; large output
datastore.sh Hyperliquid datasetTyped L2 snapshot ParquetHyperliquidDepth, spread and imbalance joined to fillsBook covers May to June 2026 only; 20-level reach
datastore.sh Phoenix and OpenBookDecoded order instructionsSolana CLOBsOrder flow and quoting behaviorNo fills or book state in these tables

For centralized exchange microstructure, an exchange-feed vendor is the right source. On-chain venues add what exchange feeds cannot: history you can check against a public ledger and order flow with signer identity. Whichever you choose, the tests that make any blockchain dataset reliable apply: defined coverage, a documented schema and versioned files.

Frequently Asked Questions

What is crypto order book data?

Crypto order book data is the record of resting buy and sell limit orders on a crypto trading venue: the size available at each price, and sometimes the number of orders at each level. Historical order book data stores that over time as snapshots, incremental updates or order events, and is used for spread, depth, liquidity and market-impact research.

What is the difference between L1, L2 and L3 order book data?

L1 is the best bid and ask with their sizes. L2 aggregates all orders at each price level into one size, often with an order count. L3 lists every individual order with its ID. L2 suits depth and slippage research; L3 is needed for queue position and order lifetimes.

Where can I get historical Hyperliquid order book data?

Hyperliquid publishes L2 snapshots in its requester-pays S3 archive, uploaded approximately monthly with no completeness guarantee. The live API returns current books only. The datastore.sh Hyperliquid Historical dataset includes an l2_order_book_snapshots table as typed Parquet, with 20 levels per side and price, size and order count per level, covering May to June 2026.

How deep are Hyperliquid order book snapshots?

The l2Book format returns up to 20 levels per side. How far that reaches depends on the market's tick size. For BTC with $1 levels, the published sample reaches only 2.5 to 3 basis points from the mid, so wider depth bands cannot be measured from these snapshots.

Can I rebuild a Solana order book from Phoenix or OpenBook data?

Not from the order instruction tables alone. They record every placement, cancellation and take order with exact prices and sizes, but fills and resting book state live in program accounts, not instruction arguments. They are suited to order-flow and quoting-behavior research. Rebuilding the book also needs account-state history or decoded fill events.

Is order book data better than trade data for backtesting?

They answer different questions. Trade data shows what executed and at what price. Order book data shows what it would have cost to execute: the spread and depth available at that moment. Realistic execution backtests need both, joined so each trade sees the book as it stood just before it.

Sources