Skip to main content

OrderQueue

Struct OrderQueue 

Source
pub struct OrderQueue { /* private fields */ }
Expand description

The per-order book, including queue order. Snapshot and event methods on Sink maintain it; Chart::order_queue reads it. At most 10,000 orders per side, with bounded resync buffering.

Implementations§

Source§

impl OrderQueue

Source

pub fn new(tick_size: Option<f64>) -> Self

An empty book, keying prices by the instrument’s positive finite tick size when known.

Source

pub fn sequence(&self) -> Option<u64>

Last applied sequence, or None until a usable snapshot or after a gap.

Source

pub fn orders(&self) -> impl Iterator<Item = &RestingOrder>

All held orders, in queue priority order. A lost book contains none.

Source

pub fn queue( &self, side: OrderSide, price: f64, ) -> impl Iterator<Item = &RestingOrder>

Orders at price, first in queue first. Prices share the aggregated book’s tick rounding.

Source

pub fn largest_order( &self, side: OrderSide, price: f64, ) -> Option<&RestingOrder>

Largest resting order at a price, if any. Ties keep the earliest queue priority.

Source

pub fn take_executions(&mut self) -> Vec<Tick>

Trades produced by accepted executions, drained once. Each fill names its resting order. At most 10,000 pending fills; the oldest make room if the host does not drain them.

Source

pub fn aggregate( &self, symbol: impl Into<String>, minimum_size: f64, ) -> OrderBook

Aggregated levels for ladders and heatmaps, counting only orders at least minimum_size. Invalid thresholds return an empty book. Counts and totals refer to the selected orders.

Source

pub fn filtered( &self, symbol: impl Into<String>, filter: &OrderFilter, ) -> Result<OrderBook, OrderFilterUnavailable>

The levels of the orders filter accepts, as the book stood at its last update: what a ladder, heatmap and book size study built on the same filter show. Fails when the held orders carry none of the metadata a filter field needs, rather than showing the unfiltered book as if it were filtered. An empty book is never unavailable.

Source

pub fn largest_orders(&self, filter: &OrderFilter) -> Vec<&RestingOrder>

The largest order filter accepts at each price of each side, bids from the highest price down and then asks from the lowest up. Ties keep the earliest queue priority.

Source

pub fn snapshot( &mut self, sequence: u64, time: DateTime<Utc>, orders: Vec<RestingOrder>, ) -> Result<(), FeedError>

Replaces all orders, then applies buffered events above sequence. A malformed snapshot clears the book. Errors leave it empty and ready for a replacement snapshot.

Source

pub fn apply( &mut self, sequence: u64, time: DateTime<Utc>, event: OrderEvent, ) -> Result<(), FeedError>

Applies exactly the next sequence. Repeated sequences are ignored. A gap clears the book and buffers at most 10,000 following events for the next snapshot.

Trait Implementations§

Source§

impl Clone for OrderQueue

Source§

fn clone(&self) -> OrderQueue

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 Debug for OrderQueue

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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.