pub enum Quote {
Mid(f64),
TopOfBook {
bid: f64,
ask: f64,
},
Sized {
bid: f64,
bid_size: f64,
ask: f64,
ask_size: f64,
},
}Expand description
One price observation for one instrument, in increasing order of
structure. Pricing reads mid regardless of variant;
the richer variants exist so marking policies (bid/ask-side marks,
microprice) have honest inputs when a trading system supplies them.
Variants§
Mid(f64)
A single price with no book behind it: a mark, settle, close or model price.
TopOfBook
Best bid and offer. mid and spread are derived on demand.
Sized
Best bid and offer with displayed sizes; enables the size-weighted
microprice.
Implementations§
Source§impl Quote
impl Quote
Sourcepub fn new(mid: f64) -> Self
pub fn new(mid: f64) -> Self
A bare mid — the compatibility constructor (marks, settles, model
prices, placeholders). Performs no validation; use
from_bid_ask for feed data.
Sourcepub fn from_bid_ask(bid: f64, ask: f64) -> Result<Self>
pub fn from_bid_ask(bid: f64, ask: f64) -> Result<Self>
Top of book. Rejects non-finite and crossed (bid > ask) input —
crossed books are a feed problem to resolve upstream, not a state
to price off.
Sourcepub fn from_bid_ask_sized(
bid: f64,
bid_size: f64,
ask: f64,
ask_size: f64,
) -> Result<Self>
pub fn from_bid_ask_sized( bid: f64, bid_size: f64, ask: f64, ask_size: f64, ) -> Result<Self>
Top of book with displayed sizes (both strictly positive and
finite), enabling microprice.
Sourcepub fn mid(&self) -> f64
pub fn mid(&self) -> f64
The mark pricing uses: the price itself for Mid,
the arithmetic bid/ask midpoint otherwise.
Sourcepub fn value(&self) -> f64
pub fn value(&self) -> f64
Alias for mid, kept for source compatibility with
the field-based Quote.
Sourcepub fn microprice(&self) -> f64
pub fn microprice(&self) -> f64
The size-weighted mid (bid * ask_size + ask * bid_size) / (bid_size + ask_size) — the standard short-horizon fair-value
estimator (leans toward the side with less displayed size). Falls
back to mid when sizes are not available.
Sourcepub fn valid_value(&self) -> bool
pub fn valid_value(&self) -> bool
Whether the mark is a usable positive price.