Skip to main content

Quote

Enum Quote 

Source
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.

Fields

§bid: f64
§ask: f64
§

Sized

Best bid and offer with displayed sizes; enables the size-weighted microprice.

Fields

§bid: f64
§bid_size: f64
§ask: f64
§ask_size: f64

Implementations§

Source§

impl Quote

Source

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.

Source

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.

Source

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.

Source

pub fn mid(&self) -> f64

The mark pricing uses: the price itself for Mid, the arithmetic bid/ask midpoint otherwise.

Source

pub fn value(&self) -> f64

Alias for mid, kept for source compatibility with the field-based Quote.

Source

pub fn bid(&self) -> Option<f64>

Best bid, when a book side was observed.

Source

pub fn ask(&self) -> Option<f64>

Best ask, when a book side was observed.

Source

pub fn spread(&self) -> Option<f64>

ask - bid, when both sides were observed.

Source

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.

Source

pub fn valid_value(&self) -> bool

Whether the mark is a usable positive price.

Source

pub fn scaled(&self, factor: f64) -> Quote

Every price level scaled by factor (a relative bump: spread and levels scale together, sizes are untouched). The quote shape is preserved — bumping a scenario must not silently discard book information.

Source

pub fn shifted(&self, delta: f64) -> Quote

Every price level shifted by delta (an absolute bump: the spread is preserved exactly, sizes are untouched).

Trait Implementations§

Source§

impl Clone for Quote

Source§

fn clone(&self) -> Quote

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Quote

Source§

impl Debug for Quote

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Quote

Source§

fn eq(&self, other: &Quote) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Quote

Auto Trait Implementations§

§

impl Freeze for Quote

§

impl RefUnwindSafe for Quote

§

impl Send for Quote

§

impl Sync for Quote

§

impl Unpin for Quote

§

impl UnsafeUnpin for Quote

§

impl UnwindSafe for Quote

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V