QuoteTick Data: Top-of-Book Prices, Sizes, and Precision Rules
Summary
QuoteTick represents a single instrument’s best available bid and ask, including the displayed size at each price and event and initialization timestamps. The document specifies the required fields and describes precision constraints: bid and ask prices must match each other in precision, as must the two sizes. The timestamps are represented in nanoseconds.
Its extraction behavior returns the bid, ask, or midpoint price, with the corresponding size available through size extraction; unsupported price types produce an error. A midpoint receives one extra precision digit, subject to a fixed maximum. Quote bars can be built using bid, ask, or midpoint prices. Rust and Python examples demonstrate constructing a quote, but the page does not discuss how quotes are collected, how long they remain valid, or how to use them in a trading strategy. It is a data-model reference for interpreting and handling top-of-book observations.
Key ideas
- A QuoteTick stores the best bid and ask prices and their displayed sizes for one instrument.
- It records both event time and initialization time in nanoseconds.
- Bid and ask prices must share precision, and bid and ask sizes must share precision.
- Price extraction supports bid, ask, or midpoint, while size extraction returns the matching size.
- The midpoint uses an additional precision digit up to a fixed limit.
Tags
Full text
# QuoteTick
# QuoteTick
`QuoteTick` represents the top-of-book bid and ask for one instrument: the best available prices
and sizes at a specific event time.
## Fields
| Field | Rust type | Python type | Required/default | Notes |
| --------------- | -------------- | -------------- | ---------------- | ---------------------------------------- |
| `instrument_id` | `InstrumentId` | `InstrumentId` | Required | Instrument for the quote. |
| `bid_price` | `Price` | `Price` | Required | Best bid price. |
| `ask_price` | `Price` | `Price` | Required | Best ask price. |
| `bid_size` | `Quantity` | `Quantity` | Required | Quantity available at the best bid. |
| `ask_size` | `Quantity` | `Quantity` | Required | Quantity available at the best ask. |
| `ts_event` | `UnixNanos` | `int` | Required | Event timestamp in nanoseconds. |
| `ts_init` | `UnixNanos` | `int` | Required | Initialization timestamp in nanoseconds. |
## Behavior
- Bid and ask prices must use the same precision.
- Bid and ask sizes must use the same precision.
- `extract_price(...)` returns the `BID`, `ASK`, or `MID` price and `extract_size(...)` returns the matching
size. Any other price type is an error.
- `MID` results carry one extra digit of precision, capped at `FIXED_PRECISION`.
- Quote bars can use `BID`, `ASK`, or `MID` price types.
## Example
```rust tab="Rust"
use nautilus_core::UnixNanos;
use nautilus_model::{
data::QuoteTick,
identifiers::InstrumentId,
types::{Price, Quantity},
};
let quote = QuoteTick::new(
InstrumentId::from("AUD/USD.SIM"),
Price::from("0.65000"),
Price::from("0.65002"),
Quantity::from("1000000"),
Quantity::from("1200000"),
UnixNanos::from(1_000_000_000),
UnixNanos::from(1_000_000_100),
);
```
```python tab="Python"
from nautilus_trader.model import InstrumentId
from nautilus_trader.model import Price
from nautilus_trader.model import Quantity
from nautilus_trader.model import QuoteTick
quote = QuoteTick(
instrument_id=InstrumentId.from_str("AUD/USD.SIM"),
bid_price=Price.from_str("0.65000"),
ask_price=Price.from_str("0.65002"),
bid_size=Quantity.from_int(1_000_000),
ask_size=Quantity.from_int(1_200_000),
ts_event=1_000_000_000,
ts_init=1_000_000_100,
)
```
## Related guides
- [OrderBookDepth](order_book_depth.md) covers variable-depth snapshots with top levels.
- [Bars and aggregation](index.md#bars-and-aggregation) covers quote-to-bar aggregation.
- [Python API reference](/docs/python-api-latest/model/data.html) lists Python members.Shown in full with attribution under the source's licence. Licence: LGPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.