ConceptsData
These docs track the unreleased nightly build and may change without notice. Switch to the latest stable docs.
OrderBookDeltas
OrderBookDeltas groups a non‑empty batch of OrderBookDelta records from one logical book event.
It reduces per‑message overhead when an adapter receives or produces several changes at once.
Fields
| Field | Rust type | Python type | Required/default | Notes |
|---|---|---|---|---|
instrument_id | InstrumentId | InstrumentId | Required | Instrument whose book is changing. |
deltas | Vec<OrderBookDelta> | list[OrderBookDelta] | Required | Non‑empty batch of deltas. |
flags | u8 | int | From last delta | Last delta flags. |
sequence | u64 | int | From last delta | Last delta sequence number. |
ts_event | UnixNanos | int | From last delta | Last delta event timestamp. |
ts_init | UnixNanos | int | From last delta | Last delta initialization timestamp. |
Behavior
- The batch must contain at least one delta.
- The batch metadata mirrors the final delta.
- The final delta should carry
F_LASTwhen it closes a logical event group. - Snapshot batches usually begin with a
CLEARdelta and end withF_SNAPSHOT | F_LAST.
Example
use nautilus_core::UnixNanos;
use nautilus_model::{
data::{BookOrder, OrderBookDelta, OrderBookDeltas},
enums::{BookAction, OrderSide, RecordFlag},
identifiers::InstrumentId,
types::{Price, Quantity},
};
let instrument_id = InstrumentId::from("ETHUSDT-PERP.BINANCE");
let bid = OrderBookDelta::new(
instrument_id,
BookAction::Add,
BookOrder::new(OrderSide::Buy, Price::from("2500.10"), Quantity::from("3.5"), 1),
0,
41,
UnixNanos::from(1_000_000_000),
UnixNanos::from(1_000_000_100),
);
let ask = OrderBookDelta::new(
instrument_id,
BookAction::Add,
BookOrder::new(OrderSide::Sell, Price::from("2500.20"), Quantity::from("2.0"), 2),
RecordFlag::F_LAST as u8,
42,
UnixNanos::from(1_000_000_000),
UnixNanos::from(1_000_000_100),
);
let deltas = OrderBookDeltas::new(instrument_id, vec![bid, ask]);Related guides
- OrderBookDelta covers the contained update type.
- Order books explains supported order book state.
- Python API reference lists Python members.
OrderBookDelta
OrderBookDelta represents one change to an order book. It is the most granular built‑in book data type and supports the book types NautilusTrader uses for...
OrderBookDepth10
OrderBookDepth10 represents a fixed‑depth book update with up to 10 bid levels and 10 ask levels. Use it when a venue publishes a self‑contained depth...