# Order Books

<details>

<summary><strong>What L2 order book data can be used for?</strong></summary>

L2 data (market-by-price) includes bids and asks orders aggregated by price level and can be used to analyze among other things:

* order book imbalance
* average execution cost
* average liquidity away from midpoint
* average spread
* hidden interest (i.e., iceberg orders)

We provide L2 data in [CSV format as incremental order book L2 updates](https://docs.tardis.dev/downloadable-csv-files/data-types#incremental_book_l2), [tick-level order book snapshots](https://docs.tardis.dev/downloadable-csv-files/data-types#book_snapshot_25) (top 25 and top 5 levels) and in [exchange-native](https://docs.tardis.dev/data#what-is-a-difference-between-exchange-native-and-normalized-data-format) format via [API and client libraries that can perform full order book reconstruction](https://docs.tardis.dev/api/quickstart) client-side.

</details>

<details>

<summary><strong>What L3 order book data can be used for?</strong></summary>

L3 data (market-by-order) includes every order book order addition, update, cancellation and match and can be used to analyze among other things:

* order resting time
* order fill probability
* order queue dynamics

Historical L3 data is currently available via API for [Bitfinex](https://docs.tardis.dev/historical-data-details/bitfinex), [Coinbase Exchange](https://docs.tardis.dev/historical-data-details/coinbase) and [Bitstamp](https://docs.tardis.dev/historical-data-details/bitstamp) - remaining supported exchanges provide [L2 data](#what-l2-order-book-data-can-be-used-for) only.

</details>

<details>

<summary><strong>What is the maximum order book depth available for each supported exchange?</strong></summary>

We always collect full depth order book data as long as exchange's WebSocket API supports it. Table below shows current state of affairs for each supported exchange.

| exchange                                                                                         | order book depth                                                                       | order book updates frequency            |
| ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | --------------------------------------- |
| [BitMEX](https://docs.tardis.dev/historical-data-details/bitmex)                                 | full order book depth snapshot and updates                                             | real-time                               |
| [Deribit](https://docs.tardis.dev/historical-data-details/deribit)                               | full order book depth snapshot and updates                                             | real-time                               |
| [Binance USDS-M Futures](https://docs.tardis.dev/historical-data-details/binance-futures)        | top 1000 levels initial order book snapshot, full depth incremental order book updates | real-time, dynamically adjusted         |
| [Binance COIN Futures](https://docs.tardis.dev/historical-data-details/binance-delivery)         | top 1000 levels initial order book snapshot, full depth incremental order book updates | real-time, dynamically adjusted         |
| [Binance Spot](https://docs.tardis.dev/historical-data-details/binance)                          | top 1000 levels initial order book snapshot, full depth incremental order book updates | 100ms                                   |
| [FTX](https://docs.tardis.dev/historical-data-details/ftx)                                       | top 100 levels initial order book snapshot and updates                                 | real-time                               |
| [OKX Futures](https://docs.tardis.dev/historical-data-details/okex-futures)                      | top 400 levels initial order book snapshot and updates                                 | real-time                               |
| [OKX Swap](https://docs.tardis.dev/historical-data-details/okex-swap)                            | top 400 levels initial order book snapshot and updates                                 | real-time                               |
| [OKX Options](https://docs.tardis.dev/historical-data-details/okex-options)                      | top 400 levels initial order book snapshot and updates                                 | real-time                               |
| [OKX Spot](https://docs.tardis.dev/historical-data-details/okex)                                 | top 400 levels initial order book snapshot and updates                                 | real-time                               |
| [HTX Coin-M Futures](https://docs.tardis.dev/historical-data-details/huobi-dm)                   | top 150 levels initial order book snapshot and updates                                 | 30ms                                    |
| [HTX Coin-M Perpetual](https://docs.tardis.dev/historical-data-details/huobi-dm-swap)            | top 150 levels initial order book snapshot and updates                                 | 30ms                                    |
| [HTX USDT-M Contracts](https://docs.tardis.dev/historical-data-details/huobi-dm-linear-swap)     | top 150 levels initial order book snapshot and updates                                 | 30ms                                    |
| [HTX Spot](https://docs.tardis.dev/historical-data-details/huobi)                                | top 150 levels initial order book snapshot and updates                                 | 100ms                                   |
| [Bitfinex Derivatives](https://docs.tardis.dev/historical-data-details/bitfinex-derivatives)     | top 100 levels initial order book snapshot and updates                                 | real-time                               |
| [Bitfinex](https://docs.tardis.dev/historical-data-details/bitfinex)                             | top 100 levels initial order book snapshot and updates                                 | real-time                               |
| [Coinbase Exchange](https://docs.tardis.dev/historical-data-details/coinbase)                    | full order book depth snapshot and updates                                             | real-time                               |
| [Coinbase International](https://docs.tardis.dev/historical-data-details/coinbase-international) | order book snapshots and deltas                                                        | real-time                               |
| [Kraken Futures](https://docs.tardis.dev/historical-data-details/cryptofacilities)               | full order book depth snapshot and updates                                             | real-time                               |
| [Kraken](https://docs.tardis.dev/historical-data-details/kraken)                                 | top 1000 levels initial order book snapshot and updates                                | real-time                               |
| [KuCoin Spot](https://docs.tardis.dev/historical-data-details/kucoin)                            | generated Level 2 order book snapshots plus Level 2 deltas                             | real-time                               |
| [KuCoin Futures](https://docs.tardis.dev/historical-data-details/kucoin-futures)                 | generated Level 2 order book snapshots plus Level 2 deltas                             | real-time                               |
| [Bitstamp](https://docs.tardis.dev/historical-data-details/bitstamp)                             | full order book depth snapshot and updates                                             | real-time                               |
| [Gemini](https://docs.tardis.dev/historical-data-details/gemini)                                 | full order book depth snapshot and updates                                             | real-time                               |
| [Poloniex](https://docs.tardis.dev/historical-data-details/poloniex)                             | full order book depth snapshot and updates                                             | real-time                               |
| [Bybit Derivatives](https://docs.tardis.dev/historical-data-details/bybit)                       | top 25 levels initial order book snapshot and updates                                  | real-time                               |
| [dYdX](https://docs.tardis.dev/historical-data-details/dydx)                                     | full order book depth snapshot and updates                                             | real-time                               |
| [dYdX v4](https://docs.tardis.dev/historical-data-details/dydx-v4)                               | order book snapshots and incremental updates                                           | real-time                               |
| [Upbit](https://docs.tardis.dev/historical-data-details/upbit)                                   | top 15 levels snapshots                                                                | real-time                               |
| [Phemex](https://docs.tardis.dev/historical-data-details/phemex)                                 | top 30 levels initial order book snapshot and updates                                  | 20ms                                    |
| [FTX US](https://docs.tardis.dev/historical-data-details/ftx-us)                                 | top 100 levels initial order book snapshot and updates                                 | real-time                               |
| [Binance US](https://docs.tardis.dev/historical-data-details/binance-us)                         | top 1000 levels initial order book snapshot, full depth incremental order book updates | 100ms                                   |
| [Crypto.com](https://docs.tardis.dev/historical-data-details/crypto-com)                         | order book snapshots and updates                                                       | real-time (5s heartbeat when unchanged) |
| [Gate.io Futures](https://docs.tardis.dev/historical-data-details/gate-io-futures)               | top 20 levels order book snapshots                                                     | unknown                                 |
| [Gate.io](https://docs.tardis.dev/historical-data-details/gate-io)                               | top 30 levels order book snapshots                                                     | unknown                                 |
| [Bitget Spot](https://docs.tardis.dev/historical-data-details/bitget)                            | top 15 levels order book snapshots                                                     | 200ms                                   |
| [Bitget Futures](https://docs.tardis.dev/historical-data-details/bitget-futures)                 | top 15 levels order book snapshots                                                     | 200ms                                   |
| [Blockchain.com](https://docs.tardis.dev/historical-data-details/blockchain-com)                 | Level 2 order book snapshots and deltas                                                | real-time                               |
| [Bitnomial](https://docs.tardis.dev/historical-data-details/bitnomial)                           | order book snapshots plus price level updates                                          | real-time                               |
| [AscendEX (BitMax)](https://docs.tardis.dev/historical-data-details/ascendex)                    | order book snapshots followed by real-time deltas                                      | real-time                               |
| [WOO X](https://docs.tardis.dev/historical-data-details/woo-x)                                   | REST-bootstrapped order book snapshots plus incremental updates                        | real-time                               |
| [Delta Exchange](https://docs.tardis.dev/historical-data-details/delta)                          | order book snapshots and incremental updates                                           | real-time                               |
| [Hyperliquid](https://docs.tardis.dev/historical-data-details/hyperliquid)                       | order book snapshots                                                                   | unknown                                 |
| [Lighter](https://docs.tardis.dev/historical-data-details/lighter)                               | order book snapshots and incremental updates                                           | 50ms                                    |
| [OKCoin](https://docs.tardis.dev/historical-data-details/okcoin)                                 | top 400 levels initial order book snapshot and updates                                 | real-time                               |
| [bitFlyer](https://docs.tardis.dev/historical-data-details/bitflyer)                             | full order book depth snapshot and updates                                             | real-time                               |
| [HitBTC (high caps)](https://docs.tardis.dev/historical-data-details/hitbtc)                     | full order book depth snapshot and updates                                             | real-time                               |
| [Binance DEX](https://docs.tardis.dev/historical-data-details/binance-dex)                       | top 1000 levels initial order book snapshot, full depth incremental order book updates | 100ms                                   |

</details>

<details>

<summary><strong>How are order book data snapshots provided?</strong></summary>

Historical market data available via [HTTP API](https://docs.tardis.dev/api/http-api-reference#data-feeds-exchange) provides order book snapshots at the beginning of each day (`00:00 UTC`) - [see details](https://docs.tardis.dev/historical-data-details/overview#collected-order-book-data-details).

We also provide custom order book snapshots with customizable time intervals from tick-by-tick, milliseconds to minutes or hours via [client libs](https://docs.tardis.dev/api/quickstart) in which case custom snapshots are computed client side from raw data provided via HTTP API as well as via [downloadable CSV files](https://docs.tardis.dev/downloadable-csv-files/overview) - [book\_snapshot\_25](https://docs.tardis.dev/downloadable-csv-files/data-types#book_snapshot_25) and [book\_snapshot\_5](https://docs.tardis.dev/downloadable-csv-files/data-types#book_snapshot_5) .

</details>

<details>

<summary><strong>Do you collect order books as snapshots or in streaming mode?</strong></summary>

Order books are collected in streaming mode - snapshot at the beginning of each day and then incremental updates. [See details](https://docs.tardis.dev/historical-data-details/overview#collected-order-book-data-details).

We also provide custom order book snapshots with customizable time intervals from tick-by-tick, milliseconds to minutes or hours via [client libs](https://docs.tardis.dev/api/quickstart) in which case custom snapshots are computed client side from raw data provided via HTTP API as well as via [downloadable CSV files](https://docs.tardis.dev/downloadable-csv-files/overview) - [book\_snapshot\_25](https://docs.tardis.dev/downloadable-csv-files/data-types#book_snapshot_25) and [book\_snapshot\_5](https://docs.tardis.dev/downloadable-csv-files/data-types#book_snapshot_5) .

</details>

<details>

<summary><strong>How incremental_book_l2 CSV dataset is built from real-time data?</strong></summary>

Cryptocurrency exchanges' real-time APIs vary a lot, but for [L2 order book data](#what-l2-order-book-data-can-be-used-for) they all tend to follow a similar flow: first, when a WS connection is established and subscription is confirmed, exchanges send an initial order book snapshot (all existing price levels or top `x` levels depending on exchange), and then start streaming order book update messages (often called deltas). Those updates, when applied to the initial snapshot, result in an up-to-date order book state at a given time.

{% hint style="info" %}
We provide initial L2 snapshots in the `incremental_book_L2` dataset at the beginning of each day (00:00 UTC, [more details](https://docs.tardis.dev/historical-data-details/overview#collected-order-book-data-details)), and also any time an exchange closes its real-time WebSocket connection, [see details](https://docs.tardis.dev/data#how-frequently-exchanges-drop-websocket-connections).
{% endhint %}

{% hint style="info" %}
Snapshot rows (`is_snapshot=true`) may contain price levels outside the nominal top-N depth advertised by the exchange (e.g., beyond top 1000 for Binance). This is because snapshots combine the exchange-provided snapshot with any incremental updates buffered during connection setup. Consumers should always reset their local order book state when encountering a new snapshot batch, regardless of depth.
{% endhint %}

Let's take FTX as an example and start with its snapshot order book message (which is frequently called 'partial' in exchange API docs as well).

Remaining bids and asks levels were removed from this sample message for the sake of clarity.

```javascript
{
  "channel": "orderbook",
  "market": "ETH/USD",
  "type": "partial",
  "data": {
    "time": 1601510401.2166328,
    "checksum": 204980439,
    "bids": [
      [
        359.72,
        121.259
      ]
    ],
    "asks": [
      [
        359.8,
        8.101
      ]
    ],
    "action": "partial"
  }
}
```

Such snapshot message maps to the following rows in CSV file:

| exchange | symbol  | timestamp        | local\_timestamp | is\_snapshot | side | price  | amount  |
| -------- | ------- | ---------------- | ---------------- | ------------ | ---- | ------ | ------- |
| ftx      | ETH/USD | 1601510401216632 | 1601510401316432 | true         | ask  | 359.8  | 8.101   |
| ftx      | ETH/USD | 1601510401216632 | 1601510401316432 | true         | bid  | 359.72 | 121.259 |

... and here's a sample FTX orderbook update message.

```javascript
{
  "channel": "orderbook",
  "market": "ETH/USD",
  "type": "update",
  "data": {
    "time": 1601510427.1840546,
    "checksum": 1377242400,
    "bids": [],
    "asks": [
      [
        360.24,
        4.962
      ],
      [
        361.02,
        0
      ]
    ],
    "action": "update"
  }
}
```

Let's see how it maps to CSV format.

| exchange | symbol  | timestamp        | local\_timestamp | is\_snapshot | side | price  | amount |
| -------- | ------- | ---------------- | ---------------- | ------------ | ---- | ------ | ------ |
| ftx      | ETH/USD | 1601510427184054 | 1601510427204046 | false        | ask  | 360.24 | 4.962  |
| ftx      | ETH/USD | 1601510427184054 | 1601510427204036 | false        | ask  | 361.02 | 0      |

See [this answer](#how-can-i-reconstruct-full-order-book-state-from-incremental_book_l2-csv-dataset) if you have doubts how to reconstruct order book state based on data provided in `incremental_book_L2` dataset.

</details>

<details>

<summary><strong>How can I reconstruct full order book state from incremental_book_L2 CSV dataset?</strong></summary>

{% hint style="info" %}
See also [how incremental\_book\_l2 CSV dataset is built from real-time data](#how-incremental_book_l2-csv-dataset-is-built-from-real-time-data).
{% endhint %}

In order to reconstruct full order book state correctly from [`incremental_book_L2`](https://docs.tardis.dev/downloadable-csv-files/data-types#incremental_book_l2) data:

* Rows before the first snapshot in the file should be skipped — they are buffered updates received before the exchange sent the initial snapshot after a connection restart.
* For each row in the CSV file (iterate in the same order as provided in file):
  * only if the local timestamp of the current row is larger than the previous row local timestamp (`local_timestamp` column value) does it mean you can read your local order book state as consistent. Why? CSV format is flat where each row represents a single price level update, but most exchanges' real-time feeds publish multiple order book level updates via a single WebSocket message that need to be processed together before reading locally maintained order book state. We use local timestamp value here to detect all price level updates belonging to a single 'update' message.
  * if current row is a part of the snapshot (`is_snapshot` column value set to `true`) and previous one was not, reset your local order book state object that tracks price levels for each order book side as it means that there was a connection restart and exchange provided full order book snapshot or it was a start of a new day (each incremental\_book\_L2 file starts with the snapshot)
  * if current row amount **is** set to zero (`amount` column value set to `0`) remove such price level (row's `price` column) from your local order book state as such price level does not exist anymore
  * if current row amount **is not** set to zero update your local order book state price level with new value or add new price level if not exist yet in your local order book state - maintain separately bids and asks order book sides (`side` column value)

Alternatively, we also provide [top 25 and top 5 levels](https://docs.tardis.dev/downloadable-csv-files/data-types#book_snapshot_25) order book snapshots as CSV datasets ready to download.

</details>

<details>

<summary><strong>Can order book snapshots be empty?</strong></summary>

Yes. For very illiquid instruments (e.g., deep out-of-the-money options or niche currency pairs) order book snapshots can be present but empty — containing no bid or ask levels. This is not a data gap; it reflects the actual state of the order book on the exchange at that time. Subsequent snapshots after reconnects may also be empty if the instrument remains illiquid.

</details>

<details>

<summary><strong>Can reconstructed order books have bid-ask overlap?</strong></summary>

Although it should never happen in theory, in practice due to various crypto exchanges bugs and peculiarities it can happen (very occasionally), see some posts from users reporting those issues:

* <https://www.reddit.com/r/BitMEX/comments/8lbj9e/bidask_ledger_weirdness/>
* <https://www.reddit.com/r/KrakenSupport/comments/emu7xc/websocket_bid_sometimes_not_being_deletedupdated/>
* <https://www.reddit.com/r/KrakenSupport/comments/d1a4nx/websocket_orderbook_receiving_wrong_bid_price_for/>
* <https://twitter.com/coinarb/status/931260529993170944>

We do track sequence numbers of WebSocket L2 order book messages when collecting the data and restart connection when sequence gap is detected for exchanges that do provide those numbers. We observe that even in scenario when sequence numbers are in check, bid/ask overlap can occur.

When such scenario occurs, exchanges tend to 'forget' to publish delete messages for the opposite side of the book when publishing new level for given side - we validated that hypothesis by comparing reconstructed order book snapshots that had crossed order book (bid/ask overlap) for which we removed order book levels for the opposite side manually (as exchange didn't publish that 'delete'), with quote/ticker feeds if best bid/ask matches (for exchanges that provide those) - see [sample code that implements that manual level removal logic](https://github.com/tardis-dev/tardis-node/blob/master/src/orderbook.ts#L65).

If you encounter a crossed book during reconstruction, the recommended approach is to remove overlapping levels from the opposite side. Additionally, crossed states are always resolved by the next snapshot reset (either at 00:00 UTC daily resubscription or after a WebSocket reconnect).

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tardis.dev/faq/order-books.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
