#[repr(align(64))]pub struct OrderBookSnapshot<const N: usize = 64> {
pub instrument_id: InstrumentId,
pub bids: SmallVec<[PriceLevel; N]>,
pub asks: SmallVec<[PriceLevel; N]>,
pub sequence_id: u64,
pub timestamp_event: u64,
pub timestamp_init: u64,
}Expand description
Full order book snapshot containing multiple price levels with const generic capacity
Optimized for HFT with cache-line alignment and SmallVec to avoid heap allocations.
This represents a complete snapshot of an order book at a specific point in time,
typically used for initial state or periodic full updates.
Fields§
§instrument_id: InstrumentIdInstrument identifier
bids: SmallVec<[PriceLevel; N]>Top bid levels (sorted by price descending)
Uses SmallVec to avoid heap allocations for normal sized order books
asks: SmallVec<[PriceLevel; N]>Top ask levels (sorted by price ascending)
Uses SmallVec to avoid heap allocations for normal sized order books
sequence_id: u64Order book sequence ID
timestamp_event: u64Unix timestamp (nanoseconds) - Order book published time (server side)
timestamp_init: u64Unix timestamp (nanoseconds) - Order book initialized time (client side)
Implementations§
Source§impl<const N: usize> OrderBookSnapshot<N>
impl<const N: usize> OrderBookSnapshot<N>
Sourcepub const fn new(
instrument_id: InstrumentId,
bids: SmallVec<[PriceLevel; N]>,
asks: SmallVec<[PriceLevel; N]>,
sequence_id: u64,
timestamp_event: u64,
timestamp_init: u64,
) -> Self
pub const fn new( instrument_id: InstrumentId, bids: SmallVec<[PriceLevel; N]>, asks: SmallVec<[PriceLevel; N]>, sequence_id: u64, timestamp_event: u64, timestamp_init: u64, ) -> Self
Create a new optimized order book depth
Sourcepub fn new_empty(
instrument_id: InstrumentId,
timestamp_init: u64,
sequence_id: u64,
) -> Self
pub fn new_empty( instrument_id: InstrumentId, timestamp_init: u64, sequence_id: u64, ) -> Self
Create a new optimized order book depth with empty bids and asks
Sourcepub fn from_arrays(
instrument_id: InstrumentId,
bids: &[(Decimal, Decimal)],
asks: &[(Decimal, Decimal)],
sequence_id: u64,
timestamp_event: u64,
timestamp_init: u64,
) -> Self
pub fn from_arrays( instrument_id: InstrumentId, bids: &[(Decimal, Decimal)], asks: &[(Decimal, Decimal)], sequence_id: u64, timestamp_event: u64, timestamp_init: u64, ) -> Self
Create an order book from arrays of price/size tuples
Sourcepub fn best_bid(&self) -> Option<PriceLevel>
pub fn best_bid(&self) -> Option<PriceLevel>
Get the best bid (highest bid price)
Sourcepub fn best_ask(&self) -> Option<PriceLevel>
pub fn best_ask(&self) -> Option<PriceLevel>
Get the best ask (lowest ask price)
Trait Implementations§
Source§impl<const N: usize> Clone for OrderBookSnapshot<N>
impl<const N: usize> Clone for OrderBookSnapshot<N>
Source§fn clone(&self) -> OrderBookSnapshot<N>
fn clone(&self) -> OrderBookSnapshot<N>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const N: usize> Debug for OrderBookSnapshot<N>
impl<const N: usize> Debug for OrderBookSnapshot<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for OrderBookSnapshot<N>
impl<const N: usize> RefUnwindSafe for OrderBookSnapshot<N>
impl<const N: usize> Send for OrderBookSnapshot<N>
impl<const N: usize> Sync for OrderBookSnapshot<N>
impl<const N: usize> Unpin for OrderBookSnapshot<N>
impl<const N: usize> UnwindSafe for OrderBookSnapshot<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.