> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Databento: how it works

Databento sells normalized exchange market data, billed per byte or on a live plan. What Taji reads from it, down to each field, is [the coverage page](https://docs.taji.is/reference/coverage/databento.md). The crate `taji-databento` (`plugins/databento/`) is a data-only source with no brokerage side. Reads go over the vendor's historical HTTP gateway, and live streams over its raw-TCP live gateway. It is the one source whose reads cost money per ask, so every buy is priced before it is made.

## The vendor

**Hosts.** The historical API is `https://hist.databento.com/v0/<endpoint>` ([get_range, HTTP](https://databento.com/docs/api-reference-historical/timeseries/timeseries-get-range.http.md), fetched 2026-12-02). The live gateway is one host per dataset. The pinned `databento` 0.65.0 crate dials `<dataset>.lsg.databento.com:13000`, the dataset lower-cased with `.` as `-`, for example `glbx-mdp3.lsg.databento.com` (its `src/live/protocol.rs`, `determine_gateway`); none of the vendor pages fetched here names that host. Taji calls no sandbox: every historical byte it buys is billed to the key's team.

**Auth.** A key is "a 32-character string starting with `db-`" ([historical authentication](https://databento.com/docs/api-reference-historical/basics/authentication.md), fetched 2026-12-02). You create keys under API keys in the portal, which the manifest's `keys` step names.
- **Historical:** the key is sent as HTTP Basic with an empty password (`curl -u $YOUR_API_KEY:` in the get_range HTTP page).
- **Live:** the gateway uses "a challenge-response authentication mechanism to ensure that your API key is never sent over the network" ([live authentication](https://databento.com/docs/api-reference-live/basics/authentication.md), fetched 2026-12-02). The pinned client implements it as CRAM.

**API families Taji calls:**

| Family | Endpoints | Vendor doc (fetched 2026-12-02) |
|---|---|---|
| Time series | `timeseries.get_range` (POST; `encoding` `dbn`/`csv`/`json`, `compression` `zstd`/`none`; `start` inclusive, `end` exclusive; filters on `ts_recv` where the schema has it, else `ts_event`; up to 2,000 symbols) | [get_range](https://databento.com/docs/api-reference-historical/timeseries/timeseries-get-range.md) |
| Metadata | `metadata.get_cost` (a float in USD; billing follows "the actual amount of bytes sent"), `metadata.list_datasets`, `metadata.get_dataset_range` | [get_cost](https://databento.com/docs/api-reference-historical/metadata/metadata-get-cost.md) |
| Symbology | `symbology.resolve` (`stype_in`/`stype_out` among `raw_symbol`, `instrument_id`, `parent`, `continuous`; up to 2,000 symbols) | [resolve](https://databento.com/docs/api-reference-historical/symbology/symbology-resolve.md), [symbology](https://databento.com/docs/standards-and-conventions/symbology.md) |
| Batch | `batch.submit_job`, `batch.list_jobs`, `batch.get_job_details`, `batch.list_files`, file download (states `queued`, `processing`, `done`, `expired`; repeat downloads free) | [submit_job](https://databento.com/docs/api-reference-historical/batch/batch-submit-job.md) |
| Live | one TCP session per dataset; subscribe by schema and symbols; `start` replays "within the last 24 hours" | [intraday replay](https://databento.com/docs/api-reference-live/basics/intraday-replay.md), [connection limits](https://databento.com/docs/api-reference-live/basics/connection-limits.md) |

Every body Taji decodes is DBN (Databento Binary Encoding): a metadata header, then fixed-length records, in versions 1 to 3 ([DBN](https://databento.com/docs/standards-and-conventions/databento-binary-encoding.md), fetched 2026-12-02). Prices are fixed-point integers in units of 1e-9, and `i64::MAX` means no price.

**Symbology.** A raw symbol is "the original string symbols used by the publisher" (`ESZ6`, not `ESZ26`). A parent is `ROOT.FUT` or `ROOT.OPT`. A continuous symbol is `ROOT.RULE.RANK`, roll rule `c`, `n` or `v`, for example `ES.c.0`. The numeric `instrument_id` is the publisher's, and "some publishers remap them daily" ([symbology](https://databento.com/docs/standards-and-conventions/symbology.md)).

**Datasets and schemas.** A dataset is one venue's feed, or one of Databento's composites. A schema is one record shape inside it: `ohlcv-*`, `trades`, `mbp-1`, `mbp-10`, `cmbp-1`, `definition`, `statistics`, `status`, `imbalance` and others. The OHLCV page says bars are "aggregated from trades", that `ts_event` is the bar's start, that an interval with no trade has no record, and that "Our `ohlcv-1d` schema is based on UTC dates" ([OHLCV](https://databento.com/docs/schemas-and-data-formats/ohlcv.md), fetched 2026-12-02).

**Entitlement.** A key reads every dataset `metadata.list_datasets` lists for it. Historical access is usage-based on any key, and you can cap the spend only in the portal. Real-time access, and an OPRA license past about one day, need a live plan. The README's [Pricing](https://docs.taji.is/catalog/databento.md#pricing), [Entitlement](https://docs.taji.is/catalog/databento.md#entitlement) and [Live](https://docs.taji.is/catalog/databento.md#live) sections hold what was measured. The manifest `taji-plugin.toml` holds the plan and cap steps.

**Stated limits** ([rate limits](https://databento.com/docs/api-reference-historical/basics/rate-limits.md), fetched 2026-12-02):
- **Historical, per team:** 100 concurrent connections; 100 time-series and 100 symbology requests a second; 20 metadata and 20 batch-list requests a second; 20 batch submits a minute.
- **429:** a request over a limit is refused 429, and "The Retry-After response header indicates how long the user should wait".
- **Live:** 10 simultaneous sessions per dataset per team on Standard, 50 on Plus or Unlimited; "at most five incoming connections per second from the same IP address"; subscription requests "capped at 10 per second", delayed rather than refused ([connection limits](https://databento.com/docs/api-reference-live/basics/connection-limits.md)).

### Offered, not read

What Taji reads is `docs/reference/coverage/databento.md`. What Databento serves past that, fetched 2026-12-04 unless a row says otherwise (*usage*: any key, billed per byte; *live*: a live plan, Standard $199 a month and up, [pricing](https://databento.com/pricing)):

| Offered | Endpoint | Plan | Source |
|---|---|---|---|
| Live streams of trades, quotes, depth and status, and replay: `open_ticks` subscribes, but `READS` lists only equity 1m bars live, because no live session is measured | live gateway, one session per dataset | live | [pricing](https://databento.com/pricing); [live overview](https://databento.com/docs/api-reference-live/basics/overview.md), 2026-12-02 |
| The history Standard includes without a per-byte charge, 1 year of L1 and 1 month of L2 and L3. Taji prices every read with `get_cost`; what that answers for an included span is unmeasured | `metadata.get_cost` | Standard | [pricing](https://databento.com/pricing) |
| Every `statistics` type the decoder has no word for: 7 lowest offer, 8 highest bid, 10 fixing, 12 net change, 13 VWAP, 14 volatility, 15 delta, 16 uncrossing, 19 block volume, 20 indicative close, 21 to 23 market-wide circuit-breaker levels, 24 to 26 auction collar, 10001 and 10002 venue-specific; and `stat_flags` (CME's settlement is final or preliminary, intraday or not) | `timeseries.get_range`, `statistics` | usage | [statistics](https://databento.com/docs/schemas-and-data-formats/statistics), [GLBX.MDP3](https://databento.com/docs/venues-and-datasets/glbx-mdp3.md) |
| An `imbalance` record's `auction_time`, `ssr_filling_price`, `upper_collar`, `lower_collar`, `market_imbalance_qty`, `unpaired_qty`, `unpaired_side`, `auction_status`, `freeze_status`, `num_extensions` and `significant_imbalance`: the `imbalance` product holds none | `timeseries.get_range`, `imbalance` | usage | [imbalance](https://databento.com/docs/schemas-and-data-formats/imbalance), [XNAS.ITCH](https://databento.com/docs/venues-and-datasets/xnas-itch.md) |
| The venue of an option print (`tcbbo` `publisher_id` "will correspond to the venue the trade executed on") and of the quote's two sides (`bid_pb_00`, `ask_pb_00`): `trades` `exchange` stays null. An `EQUS.MINI` print names none, its publisher anonymised | `timeseries.get_range`, `tcbbo` | usage; OPRA past about T-1 needs live | [TBBO](https://databento.com/docs/schemas-and-data-formats/tbbo), [OPRA.PILLAR](https://databento.com/docs/datasets/opra-pillar.md), [EQUS.MINI](https://databento.com/docs/venues-and-datasets/equs-mini.md) |
| A record's `flags`, `sequence` and `ts_in_delta`, and a book record's order counts (`bid_ct`, `ask_ct`; `EQUS.MINI`'s are always 0): `trades` and `quotes` have no column for them | `timeseries.get_range`, `trades`, `mbp-1` | usage | [trades](https://databento.com/docs/schemas-and-data-formats/trades), [mbp-1](https://databento.com/docs/schemas-and-data-formats/mbp-1) |
| `bbo-1s` and `bbo-1m`: the BBO with the last sale's price, size and side on each second or minute, which a quote's `last` could hold; `cbbo-1s`, `cbbo-1m` the consolidated counterparts (listed by `list_schemas`, README [Futures and options](https://docs.taji.is/catalog/databento.md#futures-and-options)) | `timeseries.get_range`, `bbo-1s`, `bbo-1m` | usage | [bbo](https://databento.com/docs/schemas-and-data-formats/bbo) |
| A chain row's `open_interest`: OPRA `statistics` type 9, published each morning about 6:30 ET, one record per venue; a chain row holds only the contract's name | `timeseries.get_range`, `statistics`, `ROOT.OPT` | usage | [OPRA.PILLAR](https://databento.com/docs/datasets/opra-pillar.md) |
| A listed option's other `definition` fields: `min_price_increment`, `exchange`, `currency`, `security_type`, `cfi`, `underlying_id`. A chain row keeps the OCC name, from which strike and expiry are read. `unit_of_measure_qty`, `contract_multiplier` and `original_contract_size` are undefined on OPRA (README [Open](https://docs.taji.is/catalog/databento.md#open)) | `timeseries.get_range`, `definition` | usage | [definition](https://databento.com/docs/schemas-and-data-formats/instrument-definitions) |
| A future's other `definition` fields: `currency`, `activation`, `asset`, `underlying`, `min_lot_size`, `high_limit_price`, `low_limit_price`, `market_depth`, `match_algorithm`; and the spreads (`instrument_class` not `F`, one record per leg), which `future_definition_of` drops | `timeseries.get_range`, `definition` | usage | [definition](https://databento.com/docs/schemas-and-data-formats/instrument-definitions), [GLBX.MDP3](https://databento.com/docs/venues-and-datasets/glbx-mdp3.md) |
| Trading status (halts, pauses, auction starts, short-sale restriction): `status_rows` decodes it, `READS` lists none | `timeseries.get_range`, `status` | usage | [status](https://databento.com/docs/schemas-and-data-formats/status) |
| `mbo` (order by order) and `mbp-10` outside `XNAS.ITCH` and `GLBX.MDP3`: not yet built | `timeseries.get_range`, `mbo`, `mbp-10` | usage | [schemas](https://databento.com/docs/schemas-and-data-formats) |
| `ohlcv-1s`: `DatabentoClient::schema` maps only 1m, 1h and D | `timeseries.get_range`, `ohlcv-1s` | usage | [OHLCV](https://databento.com/docs/schemas-and-data-formats/ohlcv.md) |
| `ohlcv-1d` for a future, future option or index: refused by design, it buckets by UTC date (Why, below). `OPRA.PILLAR` `ohlcv-*`: one bar per publisher, never consolidated, so option bars fold `trades` instead (README [Futures and options](https://docs.taji.is/catalog/databento.md#futures-and-options)) | `timeseries.get_range`, `ohlcv-1d` | usage | [OHLCV](https://databento.com/docs/schemas-and-data-formats/ohlcv.md) |
| Live `definition`, `statistics`, `imbalance` and `mbo`: `open_ticks` refuses the first three, `mbo` is not yet built | live gateway | live | [live overview](https://databento.com/docs/api-reference-live/basics/overview.md), 2026-12-02 |
| `csv` and `json` encodings: DBN only, Taji stores the bytes the gateway sent and parses them again on replay. Batch `split_duration` other than `none`: one file per job, which `fetch_bytes` in `plugins/databento/src/source.rs` requires. `metadata.get_record_count`, `get_billable_size`, `list_schemas`, `list_unit_prices`: called by hand for the README's measurements, never by the crate | `timeseries.get_range`, `batch.submit_job`, `metadata.*` | usage | [get_range](https://databento.com/docs/api-reference-historical/timeseries/timeseries-get-range.md), [submit_job](https://databento.com/docs/api-reference-historical/batch/batch-submit-job.md), 2026-12-02 |

## Code map

| File | Owns | Read first |
|---|---|---|
| `plugins/databento/src/lib.rs` | `Plugin`, which registers the source; `DatabentoClient`, the historical client: per-family admission, `get_range`, `get_range_bytes` (Taji's own POST), `get_cost`, `resolve`, the batch calls, error mapping (`failed`, `refused`); DBN record readers (`bar_of`, `record_of`, `statistic_of`, `imbalance_of`, `status_of`, `definition_of`, `future_definition_of`); bar routing (`bars_dataset`, `bars_schema`, `bought_span`, `raw_symbol`, `spell`); bar folding (`globex_days`, `et_days`, `fold_trades`, `parse_bars`); `impl HistoricalData` | `bars_target`, then `get_range_bytes` |
| `plugins/databento/src/source.rs` | `Databento`, the `Source`: `FACTS`, `READS`, `FILLS`, `WORDS`, `CAP`; seat, probe and key check; the catalog (`catalog`, `admit`); product routing (`schema`, `target`); record reads (`read`, `raw_read`, `records_raw`, `contracts_raw`, `chains_raw`), their parse (`parse`, `rows`); cost (`cost`, `billed`); batch fallback (`batch_job`); tick streaming (`open_ticks`) | `schema`, then `target` |
| `plugins/databento/src/live.rs` | `DatabentoStream`: the plan probe (`probe`, `PROBED`), one session per dataset (`attach`, `session_loop`, `revive`, `ended`), replay sessions (`replay`, `REPLAY_SECS`), `impl LiveStream` (1m bars on `EQUS.MINI`), `subscribe_records` | `probe`, then `session_loop` |
| `plugins/databento/src/ratelimit.rs` | The six endpoint-family budgets, one set per process (`Families`, `rate_limits`) | `Families::of` |
| `plugins/databento/src/offer.rs` | `OFFER`: what the coverage page lists as offered, each class's reach and freshness | `offered` |
| `plugins/databento/tests/egress.rs` | Taji's own POST, byte for byte against `plugins/databento/tests/egress/range.txt`; authorization and host grants | `range` |
| `plugins/databento/tests/live.rs` | The billed live tests: one SPY daily bar, and the `option_flow` hour's recording | `equity_bars_1d`, `opra_option_flow_hour_is_recorded` |
| `plugins/databento/fixtures/option_flow/` | `gen.py` writes the committed `synthetic/` hour; `classify.py` classes any hour's `tcbbo` and `definition` DBN outside Rust; `recorded/` is the bought hour, git-ignored | `classify.py` |
| `plugins/databento/taji-plugin.toml` | Identity, the `[[sources]]` id, the `databento` link form | — |

## How it plugs into Taji

**Composition.** `engine/crates/taji-open/src/lib.rs` adds `taji_databento::Plugin`, whose `build` registers `source::Databento` under the id `databento`. The plugin depends on the SDK alone, `taji-plugin` with its `vendor` feature ([ADR 0003](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0003-plugin-on-sdk-alone.md)).

**Traits:**
- `Source` (`taji_plugin::vendor`), on `Databento`;
- `HistoricalData` (`substrate/taji-brokerage/src/traits/historical_data.rs`), on `DatabentoClient`;
- `LiveStream` (`substrate/taji-brokerage/src/traits/live_stream.rs`), on `DatabentoStream`.

It implements no `VenueReads`, `ExecutionOps` or `ReconcileOps`: Databento places no orders and reads no account.

**Statics.**
- `FACTS` (`plugins/databento/src/source.rs`):
  - `seat: Key { anew: true }`;
  - `reads`, `fills` and `words` (`READS`, `FILLS`, `WORDS`);
  - `metered: true`;
  - `permits: 100`, the hub gate's shared permits, matching the vendor's 100 concurrent connections;
  - `gated` equity and future, the classes the probe decides;
  - `replay_s`, 86,400 s;
  - `stamps_book`;
  - `book`, the depth scope: ten levels, `XNAS` for equities, CME's four exchanges for futures;
  - `bars_cap: CAP`, raw prices only, metered, per-class history depth;
  - the raw formats it parses.
- `OFFER` (`plugins/databento/src/offer.rs`) feeds `GET /read/data/coverage`. Its cells are generated into [the coverage page](https://docs.taji.is/reference/coverage/databento.md).
- There is no `VenueFacts`.

**Link.** The manifest's one form, `databento`, is a single `key` field. `POST /verb/link/data/link` is refused 409 `budget_unset` until the device's data budget is set (`POST /verb/link/data/budget`). A metered provider never links without a ceiling. The link then calls `Source::check`, which prices one AAPL daily bar on `CHECK_DAY` (2024-07-01) with `metadata.get_cost` and buys nothing; `verdict` turns the answer into accepted, refused (the vendor's words) or unreachable. After the seal, `seat` builds one history client and one `DatabentoStream`, and `probe` opens and closes one live session per `PROBED` dataset (`EQUS.MINI` for equities, `GLBX.MDP3` for futures). An authenticated session grants that class `realtime`; an auth refusal grants `history`. `key_word` folds those grants into the `tier` word `GET /read/link` shows: `plan` or `usage`.

**Surfaces:**

| Taji surface | Vendor call | Made in |
|---|---|---|
| `GET /get/bars`: equity, future, future option, index, option | `timeseries.get_range`, dataset and schema per `bars_target` | `lib.rs` `bars_raw`, `parse_bars` |
| The hub's price check before a bars buy (`fetch_cost`) | `metadata.get_cost` | `lib.rs` `fetch_cost`, called from `engine/crates/taji-trading/src/hub/read.rs` |
| `GET /get/trades`, `quotes` (span), `depth`, `status` | `timeseries.get_range` of `schema(class, product)` | `source.rs` `read` |
| `GET /get/statistics`, `imbalance`, `search` (future contracts), `instrument` of a `parent:` over a range | `timeseries.get_range`, plus `symbology.resolve` for a parent's contract names | `source.rs` `records_raw`, `parse` |
| `GET /get/instrument` of a `continuous:` or `parent:` future | `symbology.resolve`, twice (symbol to ids, ids to raw symbols) | `source.rs` `contracts_raw`; `lib.rs` `resolve` |
| `GET /get/chains`, option | `timeseries.get_range` `definition` of each root's `ROOT.OPT` on `OPRA.PILLAR`, newest sellable session | `source.rs` `chains_raw`, `chain_answer` |
| `GET /get/option_flow`, an underlying | `timeseries.get_range` `tcbbo` and `definition` of each root's `ROOT.OPT` on `OPRA.PILLAR`; answers `fetch_first` (metered) | `source.rs` `option_flow` |
| The cost line of any product read | `metadata.get_cost` | `source.rs` `cost`, `billed` |
| An ask the stream refuses as oversize | `batch.list_jobs`, `get_job_details`, `submit_job`, `list_files`, download | `source.rs` `batch_job`; `lib.rs` `find_job`, `submit_job`, `job_files` |
| Refusal of a dataset the key lacks, or a date before its start | `metadata.list_datasets`, `get_dataset_range`, once per boot | `source.rs` `catalog`, `admit` |
| `GET /ws/market` equity 1m bars | live `ohlcv-1m` on `EQUS.MINI` | `live.rs` `subscribe_bars`, `session_loop` |
| `GET /ws/market` trades, quotes, depth, status, with `from` as replay | live `trades`, `mbp-1`, `mbp-10`, `cmbp-1`, `status` | `source.rs` `open_ticks`; `live.rs` `subscribe_records`, `replay` |
| `tier` in `GET /read/link` | live connect and authenticate | `live.rs` `probe`; `source.rs` `key_word` |
| `GET /read/link/rate_limits`, one `process` row | none: local budgets and the stream's symbol count | `ratelimit.rs` `rate_limits`; `live.rs` `spend` |
| `vendor_dataset` and `tier` a stored pull records (`GET /read/data/datasets`) | none | `source.rs` `catalogued` |

The live tick cells stay `offered` on the coverage page: `READS` lists only equity bars as live, because no live session has been measured.

**One read, wire to vendor and back.** `GET /get/bars` for `future:ESZ26` at `D`:
1. The hub (`engine/crates/taji-trading/src/hub/read.rs`) finds the span its store lacks. Under the provider's gate, it prices that span with `fetch_cost`. That runs `bars_target`, which answers `GLBX.MDP3`, `ohlcv-1h`, `raw_symbol`, `ESZ6`, and `bought_span`, which widens the start to the Globex open the evening before. Then `get_cost` prices it.
2. The device budget (`engine/crates/taji-trading/src/hub/budget.rs`) holds the buy against the whole spend.
3. `get_bars_session_raw` refuses an adjusted ask and an hour tier Databento does not serve natively (`hour_tier`). It then calls `bars_raw`, and `get_range_bytes` admits one `timeseries` charge (`ratelimit.rs`). It POSTs the form through `Login::send`, which reaches only `HOSTS`, with the key as Basic auth, and keeps the zstd DBN body and the form, never the key, as a `Raw` of format `databento.bars.v1`.
4. The hub keeps that raw pull and parses it through `FACTS.bars`, which is `parse_bars`. That decodes `bar_of` per record, folds the hours into Globex trade dates with `globex_days`, drops a day whose closing hour has not ended, and answers OHLCV. The hub serves Arrow.

A 429 anywhere on the way holds that endpoint family for 60 s and answers `RateLimited`. A 422 "None of the symbols could be resolved" answers `not_listed`.

There is no order path: Databento is data only.

### `option_flow`

`GET /get/option_flow` for an `equity:` or `index:` underlying is the underlying's option prints over a span of an hour at most, each with the quote standing at it (`option_flow` in `plugins/databento/src/source.rs`):
- **One record holds the print and its quote.** `OPRA.PILLAR` `tcbbo` is "every trade event alongside the consolidated BBO immediately before the effect of each trade" ([TBBO schema](https://databento.com/docs/schemas-and-data-formats/tbbo), fetched 2026-12-03), so the read joins no quotes. It asks the parent `ROOT.OPT` of each of the underlying's roots, one request per root.
- **A record names its contract by `instrument_id` alone,** so the read also buys the same parent's `definition` from the UTC midnight before the span. `raw_symbol` is the contract, and `unit_of_measure_qty` its multiplier (`definition_of`), null when undefined or not above zero: the premium is then null, and 100 is never assumed. A record with no definition is dropped. OPRA states none: the 12,540 `definition` records of SPY's options on 2026-11-25 leave `unit_of_measure_qty`, `contract_multiplier` and `original_contract_size` undefined (README [Open](https://docs.taji.is/catalog/databento.md#open)), so every premium is null and `multiplier` is no declared fill.
- **The kernel classes the side, not this plugin.** The rows state the print and the `bid` and `ask` of its quote, and the hub classes each by the shared rule (`taji_brokerage::side`, one tape per contract): the nearer side of the quote, else the contract's tick rule. OPRA states none: "OPRA does not disseminate the side of a trade, so `side` will always be `N`" ([OPRA.PILLAR](https://databento.com/docs/datasets/opra-pillar.md), fetched 2026-12-03). Nor does any schema read here state a sale condition, so `conditions` is null and the kernel's exclusion of multi-leg, late and cancelled prints, which reads OPRA letters, never fires on these rows.
- **It is metered.** `cost` prices each parent's `tcbbo` and `definition` with `get_cost`, so over the wire a read answers `fetch_first`, and the buy is the device budget's to allow. `POST /fetch` refuses `option_flow` (400, owner, 2026-12-03), so a bought hour is never stored. With Massive linked, the hub's tie order answers from it first.
- **An hour is classed twice, once outside Rust.** `fixtures/option_flow/synthetic/` is a committed hour written by `gen.py`. `classify.py` reads any hour's `tcbbo` and `definition` DBN with the vendor's `databento` package, applies the kernel's rule in `decimal`, and writes `expected.json` beside them. The recorded hour, bought by the live test, stays in `fixtures/option_flow/recorded/`, git-ignored and local: classify it with `uv run classify.py recorded` from `fixtures/option_flow/`.

## Why it is built this way

- **The vendor's own client, and one POST of Taji's own.** `databento::HistoricalClient` makes every call but the bars and stored-product reads, and `LiveClient` makes every live call. Bars and stored products post `get_range` themselves (`get_range_bytes`), because the vendor's client hands back decoded records, never the bytes, and the hub stores the bytes the gateway sent so a replay parses the same pull (`plugins/databento/src/lib.rs`, the `Stream` doc). That POST goes through egress: it reaches only `hist.databento.com` and follows no redirect (`plugins/databento/tests/egress.rs`).
- **A print's `aggressor` is stated for futures alone.** A `GLBX.MDP3` `trades` record's `side` is the initiator: `B` buy, `A` sell, `N` none (an implied trade), so `N` is null, never a tick-rule guess. `EQUS.MINI`'s page does not state `side` ([EQUS.MINI](https://databento.com/docs/venues-and-datasets/equs-mini.md), fetched 2026-12-04), so an equity's is null, and no Databento print states `off_exchange` (`source.rs` `trade_tick`; [Trades schema](https://databento.com/docs/schemas-and-data-formats/trades), fetched 2026-12-04).
- **A history print is bought with its quote.** An equity's `trades` read buys `EQUS.MINI` `tbbo` and an option's `OPRA.PILLAR` `tcbbo`, each "alongside the BBO immediately before the effect of each trade" ([TBBO schema](https://databento.com/docs/schemas-and-data-formats/tbbo), fetched 2026-12-03), and `trade_tick` fills the print's `bid` and `ask` from the record's one level. The kernel classes the print against them before any other quote (`taji_brokerage::side`), so no quotes read is joined or bought (owner, 2026-12-03: "let's use trades with quotes. no need to price it"). A future's stay `trades`. A live print streams `trades` (`live_schema`): a live `tbbo` frame is an `mbp-1` one, so its quote is the hub's live one.
- **Fills rest on the vendor's own statements.** A print's `bid` and `ask` are the one level of its `tbbo` or `tcbbo` record, and `EQUS.MINI`'s one BBO sums the sizes across venues ([TBBO](https://databento.com/docs/schemas-and-data-formats/tbbo), [EQUS.MINI](https://databento.com/docs/venues-and-datasets/equs-mini.md), fetched 2026-12-04). A depth row's `count` is `mbp-10`'s `bid_ct` and `ask_ct`. A statistics fill is a stat it states: the open and close crosses on `XNAS.ITCH`, settlement and open interest on `GLBX.MDP3` (README [Futures and options](https://docs.taji.is/catalog/databento.md#futures-and-options)) and open interest on OPRA. An imbalance's near and far prices are stated from 9:28 and 15:55 ET, empty before ([XNAS.ITCH](https://databento.com/docs/venues-and-datasets/xnas-itch.md), fetched 2026-12-04). An option bar's `vwap` is the plugin's fold of its prints, the 1m bar's alone. Future `search` rows have no typed decoder, so none is declared.
- **The key is revealed to the vendor's clients.** Live CRAM signs a challenge with the key itself, so no header marker can stand in for it (`reveals` in `plugins/databento/src/source.rs`). The key still never reaches a client or a process plugin ([ADR 0005](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0005-no-key-reaches-a-client.md)).
- **Every buy is priced first.** Databento is the first provider whose bars cost money, so `fetch_cost` is what the device budget reads, and a metered link is refused until that budget is set. `get_cost` is free metadata.
- **A dataset per class, from measurement.** Each choice follows a fact measured in the README:
  - an equity's daily bar comes from `EQUS.SUMMARY`, because `EQUS.MINI`'s daily bar holds about 5% of the consolidated volume and trades outside the regular session ([Dataset](https://docs.taji.is/catalog/databento.md#dataset));
  - a future's daily bar is `ohlcv-1h` summed by Globex trade date, because `ohlcv-1d` buckets by UTC date and so holds the next session's first hours ([What Taji uses](https://docs.taji.is/catalog/databento.md#what-taji-uses));
  - an index's daily bar is hours summed by New York date;
  - an option's bars are folded from `trades`, because `OPRA.PILLAR` `ohlcv-*` is one bar per publisher ([Futures and options](https://docs.taji.is/catalog/databento.md#futures-and-options)).
- **Data as the vendor gives it.** `CAP.adjustments` is `Raw` alone, and an adjusted ask is refused, not adjusted here ([ADR 0007](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0007-vendor-basis-as-given.md)).
- **A capability through a hub product.** Statistics, imbalance, status, depth scope, futures listings and chains are platform products a second provider could fill, never Databento-named routes ([ADR 0004](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0004-capabilities-through-the-hub.md)).
- **The plan is detected, never typed.** The live gateway authenticating a key is the plan, and a refusal is history. `check` uses the historical gateway instead, because the live one refuses a usage key with the same auth error a wrong key gets (`probe` in `plugins/databento/src/live.rs`, `check` in `plugins/databento/src/source.rs`).
- **The catalog is free and asked once per boot.** A read of a dataset the key lacks is `NoSource` before any billed call, and a date before the dataset's start is refused with that start.
- **Batch is looked at once, never waited on.** A read runs under the hub's store lock, so `batch_job` adopts a matching vendor job (a restart forgets its own), submits one only when none exists, and answers "ask again" until the job is `done`. A submit whose answer is lost may be billed and queued, so it is held as `databento_submit_unconfirmed` and never sent again; the vendor's portal is where you check it.
- **A 429 holds the family 60 s.** The vendor's client keeps `Retry-After` to itself, so `api_failed` cannot honour it.
- **One live session per dataset.** A session binds one dataset. Each `(schema, symbol)` is subscribed once while any consumer holds it and fans out to its consumers, so a re-attach never sends a second subscribe, which would deliver every record twice; the session unsubscribes it at its first prune (`PRUNE`) after the last consumer goes. A dropped session is dialled again with backoff to `MAX_BACKOFF`, every held subscription sent again, and ends for good only when the gateway refuses the key. A replay (`from`) runs on its own session, so history never reaches a real-time consumer (`plugins/databento/src/live.rs`).
- **A chain steps back up to three sessions.** Today's `definition` is 422 until the session ends, and a usage key's OPRA license stops about one session back, both measured 2026-09-24 (`CHAIN_STEPS`).
- **A future's raw symbol carries a one-digit year.** `raw_symbol` cuts `ESZ26` to `ESZ6`, because `GLBX.MDP3` resolves only that spelling. A future option keeps its single space (`ESZ6 C7800`), and an index loses its `$`.
- **A dated contract's `instrument` is refused.** `FACTS.symbology` refuses `raw_symbol`: this source resolves continuous and parent futures, and another provider answers a dated contract.

## Constraints and limits

- **Rate budgets.** `plugins/databento/src/ratelimit.rs` holds one `Budget` per endpoint family: `timeseries`, `symbology`, `metadata`, `batch_list` and `batch_submit` at the vendor's stated rates, and `batch_files` unlimited (the vendor states none). `Families::of` maps an endpoint to its family, and every call is admitted by `queue::admit` before it is sent.
  - The set is one per process (`Families::gateway`). The vendor counts per team ("Our historical API allows each team up to", fetched 2026-12-02), with no per-IP limit, so every Databento client in the process shares the set whatever its key. A client aimed at a mock server holds its own.
  - On top, the hub's gate gives the provider 100 shared permits (`FACTS.permits`).
- **Stream caps.** One session per dataset per process. `spend` reports the distinct symbols carried, with no quota. The vendor's per-team session caps and 5 connects a second per IP are on its page; the README's [Open](https://docs.taji.is/catalog/databento.md#open) lists them as unmeasured. The pinned client splits a subscribe into messages of 500 symbols itself. Each fan-out buffers 512 events (`DEPTH`), and a slower consumer hears `Lagged`.
- **Replay.** A live `from` must fall within the last 86,400 s, else Taji refuses it before connecting (`replay_start`). The gateway answers an older one 422 `no_replay` (README [What Taji uses](https://docs.taji.is/catalog/databento.md#what-taji-uses)).
- **Entitlement.**
  - A dataset not in `list_datasets` is `NoSource`.
  - A span before `get_dataset_range`'s start names that date.
  - A 403 `license_not_found_unauthorized` is the span's refusal (`Refused`), not the key's; every other 401 or 403 is `Auth`.
  - Live access and OPRA past about T-1 need a plan (README [Futures and options](https://docs.taji.is/catalog/databento.md#futures-and-options)).
- **Symbology.** `spell` maps a `continuous:` item to `stype_in=continuous` (roll letter lower-cased), a `parent:` item to `parent`, and an instrument to its raw symbol. Spreads, series and other continuous spellings are `Unsupported`. The live gateway subscribes raw symbols alone.
- **Bars.**
  - 1m, 1h and D only. 5m and 30m are folded by the hub from 1m.
  - Native 1h only for an equity's extended session and a future's sessions; every other 1h, and every 4h, is the hub's to fold (`hour_tier`).
  - No `24h` session: `EQUS.MINI` is exchange-only.
  - A daily bar whose day has not fully been served is dropped, not shown forming.
- **Refusals the hub reads.**
  - 422 "None of the symbols could be resolved" is `not_listed`.
  - 422 naming batch or size is `oversize`, which sends the ask to batch.
  - Any other 400 or 422 is `Refused` in the vendor's `case: message`.
  - A transport failure is `Network`.
- **Numbers.** Prices, record counts and dataset start dates are the README's: [Pricing](https://docs.taji.is/catalog/databento.md#pricing), [Entitlement](https://docs.taji.is/catalog/databento.md#entitlement), [Auth and calls](https://docs.taji.is/catalog/databento.md#auth-and-calls), [Indexes and future options](https://docs.taji.is/catalog/databento.md#indexes-and-future-options), [Records](https://docs.taji.is/catalog/databento.md#records).

## Examples

**Taji's request to the vendor.** This is the golden that `plugins/databento/tests/egress.rs` `range` asserts, from `plugins/databento/tests/egress/range.txt`. The test sends it to a loopback upstream with the synthetic test key. The authorization value is that key, base64-encoded with an empty password, masked here:

```
http POST /v0/timeseries.get_range
accept: application/octet-stream
accept-encoding: gzip
authorization: Basic p1
content-length: 170
content-type: application/x-www-form-urlencoded
user-agent: taji-databento/0.1.0
body dataset=GLBX.MDP3&schema=ohlcv-1m&encoding=dbn&compression=zstd&stype_in=raw_symbol&stype_out=instrument_id&symbols=ESZ6&start=1704205800000000000&end=1704205860000000000
```

The vendor's answer is a zstd DBN stream, so no text capture exists. No DBN capture is kept either: the offline tests encode their records in memory (`RecordEncoder` in `plugins/databento/src/lib.rs` and `plugins/databento/src/live.rs`). `DATABENTO_LIVE=1 cargo test -p taji-databento --test live -- --ignored --test-threads=1` buys one such answer, but it does not write it to disk.

**The vendor's refusal of a wrong key.** This is the body `a_wrong_key_is_refused_in_the_vendors_words` in `plugins/databento/src/lib.rs` replays on `/v0/metadata.get_cost`, as measured 2026-09-24:

```json
{"detail":{"case":"auth_authentication_failed","message":"Authentication failed.","status_code":401,"docs":"https://databento.com/docs/portal/api-keys","payload":null}}
```

`refused` maps it to `Auth`, and `verdict` makes it a refused link, with "Authentication failed." as the reason.

**The kernel's answer.** `engine/crates/taji/tests/fixtures/wire/data-depth.json` is `GET /get/depth` for `equity:SPY` with `databento` serving. The rows come from the fixture's stand-in body (`tick_answer` in `engine/crates/taji/src/wire/fixture.rs`, shaped as Databento's `mbp-10` records). The `scope` comes from `FACTS.book`:

```json
"metadata": {
  "provider": "{\"equity:SPY\":\"databento\"}",
  "scope": "{\"levels\":10,\"venues\":[\"XNAS\"]}",
  "source": "{\"equity:SPY\":\"vendor\"}"
},
"rows": 4,
```

Its `pretty` field, unescaped and cut to the first two rows:

```
| symbol | ts_event            | ts_init             | side | level | price          | size           | count | peak | step |
| SPY    | 1791469798998750000 | 1791469799000000000 | bid  | 0     | 501.2400000000 | 300.0000000000 | 3     |      |      |
| SPY    | 1791469798998750000 | 1791469799000000000 | ask  | 0     | 501.2600000000 | 200.0000000000 | 2     |      |      |
…
```

`ts_init` is the record's `ts_recv`, the instant Databento received it, and the read cuts on it. `ts_event` is the venue's own stamp. `engine/crates/taji/tests/fixtures/wire/data-statistics.json` (ESZ26 settlement, `stat_type` 3) and `engine/crates/taji/tests/fixtures/wire/data-imbalance.json` are built the same way.

**The link.** `engine/crates/taji/tests/fixtures/wire/link-linked.json` shows a Databento key accepted at `plan`. In `data`, `databento` reads `"tier": "plan"`, and `metered` is `["databento"]`.

**Live.** No capture yet. The live tests run only with a plan key, and SKIP until one exists.

## Testing

| What | Command | Needs |
|---|---|---|
| Offline unit tests: routing, spelling, folding, DBN readers, refusals, batch states over `wiremock`, live fan-out and replay window | `cargo test -p taji-databento` | nothing |
| Egress golden, authorization, redirect and host grants | `cargo test -p taji-databento --test egress` | nothing |
| The hub's seeded `FACTS` and the `process` rate-limit row | `cargo test -p taji-trading` | nothing |
| Unbilled resolve and price of an index and a future option | `cargo test -p taji-databento -- --ignored live_` | `DATABENTO_API_KEY` in the environment |
| One billed SPY daily bar, refused above $1.00 by `get_cost` first | `DATABENTO_LIVE=1 cargo test -p taji-databento --test live -- --ignored --test-threads=1` | `DATABENTO_LIVE=1` and `DATABENTO_API_KEY`; otherwise each test is a SKIP cell |
| Price, and with `DATABENTO_BUY_OK=1` buy, the `option_flow` hour into `fixtures/option_flow/recorded/` (the buy is real money: set it only on the owner's yes to the printed cost) | `DATABENTO_LIVE=1 cargo test -p taji-databento --test live -- --ignored --test-threads=1 opra_option_flow_hour_is_recorded` | `DATABENTO_LIVE=1` and `DATABENTO_API_KEY`; without `DATABENTO_BUY_OK=1` it prints `SKIP buy_unconfirmed cost=<usd>` and buys nothing |
| Every vendor's live leg | `engine/crates/taji-open/scripts/vendor_live.sh databento` | never sets `DATABENTO_LIVE`, so Databento reports SKIP |

There are no captured fixtures under `plugins/databento/tests/`: the unit tests build each DBN record in memory, and the `option_flow` hour's fixtures are under `plugins/databento/fixtures/option_flow/`. There is no walk script, and no paper or SIM leg, because nothing here trades. When the wire fixture's Databento bodies change, regenerate them per the wire-fixture row of `AGENTS.md`.

## References

All fetched 2026-12-02:

- [Historical authentication](https://databento.com/docs/api-reference-historical/basics/authentication.md)
- [Historical rate limits](https://databento.com/docs/api-reference-historical/basics/rate-limits.md)
- [timeseries.get_range](https://databento.com/docs/api-reference-historical/timeseries/timeseries-get-range.md), [HTTP form](https://databento.com/docs/api-reference-historical/timeseries/timeseries-get-range.http.md)
- [metadata.get_cost](https://databento.com/docs/api-reference-historical/metadata/metadata-get-cost.md)
- [symbology.resolve](https://databento.com/docs/api-reference-historical/symbology/symbology-resolve.md)
- [batch.submit_job](https://databento.com/docs/api-reference-historical/batch/batch-submit-job.md)
- [Live authentication](https://databento.com/docs/api-reference-live/basics/authentication.md)
- [Live intraday replay](https://databento.com/docs/api-reference-live/basics/intraday-replay.md)
- [Live connection limits](https://databento.com/docs/api-reference-live/basics/connection-limits.md)
- [Live overview](https://databento.com/docs/api-reference-live/basics/overview.md)
- [OHLCV schema](https://databento.com/docs/schemas-and-data-formats/ohlcv.md)
- [Trades schema](https://databento.com/docs/schemas-and-data-formats/trades)
- [Symbology](https://databento.com/docs/standards-and-conventions/symbology.md)
- [DBN](https://databento.com/docs/standards-and-conventions/databento-binary-encoding.md)

Fetched 2026-12-03:

- [TBBO and TCBBO schemas](https://databento.com/docs/schemas-and-data-formats/tbbo)
- [OPRA.PILLAR](https://databento.com/docs/datasets/opra-pillar.md)
