pub struct OrderBookState { /* private fields */ }Expand description
Local L2 order book for a Spot symbol.
Built from a REST depth snapshot plus the <symbol>@depth diff stream.
Snapshots and diffs may be fed in any order; the state machine handles
buffering, draining stale events, bridging, and live-chain verification
internally.
Implementations§
Source§impl OrderBookState
impl OrderBookState
pub fn new() -> Self
Sourcepub fn apply_snapshot(&mut self, snapshot: OrderBook) -> ApplyOutcome
pub fn apply_snapshot(&mut self, snapshot: OrderBook) -> ApplyOutcome
Feed a REST depth snapshot into the state machine.
Sourcepub fn apply_diff(&mut self, diff: DepthUpdateMsg) -> ApplyOutcome
pub fn apply_diff(&mut self, diff: DepthUpdateMsg) -> ApplyOutcome
Feed a live diff event into the state machine.
pub fn is_synced(&self) -> bool
pub fn last_update_id(&self) -> Option<i64>
pub fn bids(&self) -> Option<&BTreeMap<Decimal, Decimal>>
pub fn asks(&self) -> Option<&BTreeMap<Decimal, Decimal>>
pub fn best_bid(&self) -> Option<(Decimal, Decimal)>
pub fn best_ask(&self) -> Option<(Decimal, Decimal)>
Trait Implementations§
Source§impl Debug for OrderBookState
impl Debug for OrderBookState
Source§impl Default for OrderBookState
impl Default for OrderBookState
Source§fn default() -> OrderBookState
fn default() -> OrderBookState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OrderBookState
impl RefUnwindSafe for OrderBookState
impl Send for OrderBookState
impl Sync for OrderBookState
impl Unpin for OrderBookState
impl UnsafeUnpin for OrderBookState
impl UnwindSafe for OrderBookState
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
Mutably borrows from an owned value. Read more