> This page is for Datasets.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.immix.xyz/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.immix.xyz/_mcp/server.

# incremental_book_L2

**Family** `incremental_book_L2` · **Since** contract `2.2.0` · **Rows per fact** many

**Key** `incremental_book_L2/{exchange}/{yyyy-MM-dd}/{encoded_symbol}.{sha12}.csv.gz`

`incremental_book_L2`: `exchange_seq,is_snapshot,row_reason,side,price,amount`. The whole
book, as rows a reader can rebuild it from: one row per price level per book fact. `side` is
`bid` or `ask`. `is_snapshot` is `true` on a row of a whole-book group and `false` on a row
that changes one level. `row_reason` says why a row is there when no delta on the stream
carried it, and is empty when one did. [Rebuilding a book](/datasets/reference/files/incremental-book-l2#rebuilding-a-book) has the rule
and what each value means.

## Columns

Every family begins with the same 9 columns, in this order; the family's own follow them.

| Column               | Type       | May be empty | Notes                                                                                                                                                             |
| -------------------- | ---------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `exchange`           | `string`   | No           | Exchange code from refdata, for example `OKX`                                                                                                                     |
| `symbol`             | `string`   | No           | Canonical symbol, for example `BTC/USDT`                                                                                                                          |
| `instrument`         | `string`   | No           | Gateway spelling, `EXCHANGE@SYMBOL`                                                                                                                               |
| `exchange_symbol`    | `string`   | No           | Venue spelling, for example `BTC-USDT`                                                                                                                            |
| `instrument_id`      | `int64`    | No           | Signed 64-bit refdata identifier                                                                                                                                  |
| `timestamp`          | `epoch_ns` | No           | Sequencer consensus time, epoch ns                                                                                                                                |
| `exchange_timestamp` | `epoch_ns` | Yes          | Exchange time, epoch ns; empty when absent                                                                                                                        |
| `local_timestamp`    | `epoch_ns` | Yes          | Connector socket-read time, epoch ns; empty when absent                                                                                                           |
| `global_sequence`    | `int64`    | No           | The fact's envelope ordinal in the source stream. It identifies a row where a fact writes at most one; the rows one fact writes to `incremental_book_L2` share it |
| `exchange_seq`       | `int64`    | Yes          |                                                                                                                                                                   |
| `is_snapshot`        | `boolean`  | No           |                                                                                                                                                                   |
| `row_reason`         | `enum`     | Yes          | One of `restated`, `checkpoint`, `window`.                                                                                                                        |
| `side`               | `enum`     | Yes          | One of `bid`, `ask`.                                                                                                                                              |
| `price`              | `decimal`  | Yes          |                                                                                                                                                                   |
| `amount`             | `decimal`  | Yes          |                                                                                                                                                                   |

## A file's first lines

**`incremental_book_L2: the header, and a row's shape`**

```csv title="incremental_book_L2: the header, and a row's shape"
exchange,symbol,instrument,exchange_symbol,instrument_id,timestamp,exchange_timestamp,local_timestamp,global_sequence,exchange_seq,is_snapshot,row_reason,side,price,amount
<string>,<string>,<string>,<string>,<int64>,<epoch_ns>,<epoch_ns>,<epoch_ns>,<int64>,<int64>,<boolean>,<restated|checkpoint|window>,<bid|ask>,<decimal>,<decimal>
```

The second line is a row's shape, read off the contract: `<decimal>` stands for a value of that type, an enum shows its values, and a cell that may be empty is marked in the table above.

## Emission

One row per price level per book fact the fold applied; the rows of one fact share its global_sequence and are contiguous. A delta writes the levels it carried, in its order, is_snapshot=false and row_reason empty; an amount of zero removes the level. A delta the fold ignored writes nothing. A restatement writes the whole book, is_snapshot=true and row_reason=restated, asks ascending then bids descending, when the book was not synced before it or it changes a level or a scale; one that leaves a synced book exactly as it was writes nothing. Checkpoint: unless the first fact of the hour applied to a book is a restatement written whole, the book as it stood before that fact is written whole first, is_snapshot=true and row_reason=checkpoint, under that fact's clocks and global_sequence and the book's own exchange_seq. Window: after a delta's own rows, every level a depth window dropped is a removal with row_reason=window. A whole-book group for a book with no levels is one row with empty side, price and amount.

## Rebuilding a book

A reader of `incremental_book_L2` applies its rows a run at a time. This is the whole rule, as
[the contract](/datasets/reference/files/overview) states it
under the family's `rebuild`:

```
keep one book for each instrument_id
for each run of rows sharing one global_sequence and one is_snapshot, in file order:
    take the book of the run's instrument_id
    if the run's is_snapshot is true: forget that book
    for each row of the run that has a side:
        if is_snapshot is false and amount is zero: remove (side, price)
        otherwise: set (side, price) to amount
```

It needs no sequence chaining, no checksum, no depth rule for any venue and no rule for matching
one row's price to another's. From one whole-book group to the next every row of a book is at
one pair of scales, so a level has one spelling: a reader that keys on the text of the `price`
cell and one that keys on its value hold the same book. A zero `amount` is written at the
book's scale like any other, `0` or `0.000`. The rule never reads `row_reason`.

Three lines of it are where a reader ported from another format goes wrong:

* **"If the run's `is_snapshot` is true: forget that book."** Every whole-book group starts its
  book afresh, also one that follows another with no delta between them: a run ends where
  `global_sequence` changes, not only where `is_snapshot` does. A checkpoint followed by a
  restatement that changes the book, and two re-anchors of a quiet book, are neighbours of this
  kind. A reader that discards its book only when `is_snapshot` turns true after false keeps
  levels the second group dropped.
* **"Keep one book for each `instrument_id`."** A file is one symbol's, and a symbol is almost
  always one instrument. Where a successor instrument takes a symbol over, the delisted
  instrument keeps the name for the rest of that hour, so rows of both can sit in one file,
  each with its own `instrument_id` and its own whole-book groups.
* **"For each row of the run that has a side."** A row with no `side` is the one row of a
  whole-book group for a book that holds no level: its run forgets the book and sets nothing.

**Where the book holds.** The book the rule builds is the published book from that book's first
whole-book group on. It stops being so at the start of any gap that covers the family, a
`book_unsynced` gap of it or a gap whose family is `*` (`connector_disconnected`), and at any
hour that is failed or absent: a failed hour has no files and, in its own manifest, no gaps,
and the day manifest lists it as a `*` gap over the hour. From there the book is unknown until
its next whole-book group, so a reader carries a book only from one `ok` hour into the next.
Past a failed hour in a day file that group can lie well into the next hour: it is that hour's
checkpoint, and so also the book from that hour's start.

What the rows are:

* **A delta** that applied to the book writes the levels it carried, in the order it carried
  them: `is_snapshot=false`, `row_reason` empty. The rows of one fact share its
  `global_sequence` and its clocks, and sit together. A delta with no level writes no row.
* **`restated`**: the stream restated the whole book, and the book was unknown before it or
  the restatement changed it, in a level or in a scale. The rows are the whole book, asks
  ascending then bids descending. A restatement that leaves a known book exactly as it was
  writes nothing, so a `restated` group always means that the book in front of you is not one
  its deltas had built. It stands for every change since the row before it: the separate
  updates inside, and their times, were never on the stream.
* **`checkpoint`**: the publisher's own image, written once an hour and not a fact of the
  stream. Unless the first fact of the hour that applies to a book is a `restated` group, the
  book as it stood before that fact is written whole first, under that fact's clocks and
  `global_sequence` and the `exchange_seq` the book held. The fact's own rows follow, which is
  why a run is split on `is_snapshot` as well. Nothing applied to the book between the hour's
  start and that fact, so the checkpoint is also the book as the hour began; for an instrument
  first named inside the hour it is the book before its first named fact. Every hour file, and
  every hour of a day file, therefore opens each book on a whole-book group and rebuilds on
  its own. A reader that carried the book out of the hour before already holds the checkpoint:
  applying it changes nothing, and skipping it loses nothing.
* **`window`**: a removal the venue did not send. Some venues keep a fixed depth window and
  say nothing when a level slides out of it. The publisher writes each such level as a removal
  behind the delta's own rows, in the delta's group, so the rule above stays the whole of what
  a reader does. The level left the view; it may still stand in the venue's book. A reader
  counting cancellations sets these rows aside. None of the three exchanges published today
  states a window.

A reader that wants only what the stream's deltas said keeps the rows whose `row_reason` is
empty. `exchange_seq` is the venue's sequence after the fact, or the sequence a checkpoint's
book held; it is empty where the venue has none.

What the full-depth book can and cannot say, whatever the format:

* **The depth is the subscribed channel's**, a connector setting for each venue. In production
  on 2026-11-11 the largest restated book held 100 levels over both sides on BYBIT and 800 on
  OKX.
* **The BINANCE_SPOT book is its top 100 a side at each re-anchor, plus what has changed
  since.** The stream is the venue's diff channel over a 100-level snapshot. A level between
  the hundredth at the last anchor and the hundredth now is absent until it changes or the next
  anchor arrives, and what was learned beyond the hundredth is dropped at each anchor.
* **It is price-aggregated depth at the venue's cadence**, 100 ms on BINANCE_SPOT and OKX.
  Nothing on the stream is order by order, so queue position is not observable.
* **Each book is re-anchored about every five minutes** on the three published exchanges, none
  of which sends a checksum the connector can verify: the book is fetched or subscribed again,
  and what changed meanwhile arrives as one `restated` group, not as deltas. The book is exact
  from that group on.

CSV is UTF-8 with LF endings and ordinary CSV quoting (quotes doubled inside quoted cells).
An empty cell is null. The header is its own gzip member; bodies may contain multiple
members because writer handles are bounded. Standard readers must consume concatenated
gzip members. A day has exactly one header, followed by its hours' headerless bodies.