Skip to main content

rustrade_data/exchange/databento/
mod.rs

1//! Databento market data connectors for historical and live data.
2//!
3//! Provides access to institutional-grade market data with nanosecond precision
4//! across equities, futures, options, and crypto futures via CME.
5//!
6//! # Architecture
7//!
8//! Unlike WebSocket-based connectors (Binance, Alpaca), Databento uses high-level
9//! client wrappers that handle connection management internally:
10//!
11//! - [`DatabentoHistorical`](crate::exchange::databento::DatabentoHistorical): One-shot queries for data older than 24 hours
12//! - [`DatabentoLive`](crate::exchange::databento::DatabentoLive): Real-time streaming for live and intraday replay data
13//!
14//! # Connection Model
15//!
16//! - **One connection per dataset**: Each client connects to one dataset (e.g., GLBX.MDP3)
17//! - **Multiple symbols per connection**: Databento recommends consolidating subscriptions
18//! - **Connection limits**: 10/dataset (standard) or 50/dataset (enterprise)
19//!
20//! # Authentication
21//!
22//! Requires `DATABENTO_API_KEY` environment variable from an active Databento
23//! subscription.
24//!
25//! # ⚠️ Data licensing — redistribution is prohibited
26//!
27//! This crate is MIT-licensed. That covers **our code** and says nothing about the **data** a
28//! Databento subscription retrieves through it.
29//!
30//! Databento licenses market data per subscriber. Its User Agreement defines "Redistribution" to
31//! cover the publication or distribution of covered data and "all other means of furnishing such
32//! data or other information derived from the same to entities other than Customer", and requires
33//! the customer to limit use to internal purposes and "not to engage in any Redistribution of
34//! Third-Party Data" — except where permitted by the relevant exchange's own agreement or by prior
35//! written approval from both that exchange and Databento, each in their sole discretion. Much of
36//! what is reachable here is exchange data (`GLBX.MDP3` is CME Group), so both gates apply.
37//!
38//! In practice, for anyone using this module:
39//!
40//! - **Do not commit retrieved data** — not as test fixtures, example datasets, CI artifacts or
41//!   golden files. This repository's offline tests generate synthetic DBN records for exactly this
42//!   reason rather than replaying a capture.
43//! - Records you receive are for your own internal use; passing them on, or deriving a feed or
44//!   product from them for third parties, needs written permission you almost certainly do not
45//!   have by default.
46//!
47//! Terms: <https://databento.com/legal/databento-user-agreement>
48//!
49//! # Testing Status
50//!
51//! **NOT tested in CI** — no permission to use credentials for CI.
52//!
53//! **Tested locally:**
54//! - Offline fixture tests (`databento_transformer.rs`): DBN-to-rustrade transformation
55//!
56//! **NOT tested locally (no subscription, no sandbox keys):**
57//! - Historical API (`databento_integration.rs`): authentication, queries
58//! - Live streaming (`databento_integration.rs`): WebSocket connection, data reception
59//!
60//! # Datasets
61//!
62//! | Dataset | ExchangeId | Description |
63//! |---------|------------|-------------|
64//! | GLBX.MDP3 | `DatabentoGlbx` | CME Globex futures |
65//! | XNAS.ITCH | `DatabentoXnas` | Nasdaq equities |
66//! | XNYS.PILLAR | `DatabentoXnys` | NYSE equities |
67//! | DBEQ.MAX | `DatabentoDbeq` | Composite US equities |
68//! | OPRA.PILLAR | `DatabentoOpra` | US options consolidated |
69
70mod error;
71pub mod historical;
72pub mod live;
73pub(crate) mod transformer;
74
75pub use error::DatabentoErrorKind;
76pub use historical::{
77    DatabentoHistorical, DatabentoOhlcvParams, load_quotes_from_dbn, load_trades_from_dbn,
78};
79pub use live::DatabentoLive;