pub struct MarketDepth { /* private fields */ }Expand description
A price-aggregated (L2) snapshot of one instrument’s book: bids best (highest) first, asks best (lowest) first. Validated on construction — sorted sides, positive finite sizes, uncrossed top — so consumers can walk it without re-checking.
Implementations§
Source§impl MarketDepth
impl MarketDepth
Sourcepub fn new(bids: Vec<DepthLevel>, asks: Vec<DepthLevel>) -> Result<Self>
pub fn new(bids: Vec<DepthLevel>, asks: Vec<DepthLevel>) -> Result<Self>
Build a validated book. Either side may be empty (a one-sided
market); a crossed top (best_bid > best_ask) is rejected.
pub fn bids(&self) -> &[DepthLevel]
pub fn asks(&self) -> &[DepthLevel]
pub fn best_bid(&self) -> Option<DepthLevel>
pub fn best_ask(&self) -> Option<DepthLevel>
Sourcepub fn vwap_for_size(&self, side: Transection, quantity: f64) -> Option<f64>
pub fn vwap_for_size(&self, side: Transection, quantity: f64) -> Option<f64>
Volume-weighted average execution price for quantity, walking
the book: a Buy lifts asks, a Sell hits bids. None when the
displayed depth cannot fill the quantity (or it is not positive) —
the honest answer, not an extrapolation.
Sourcepub fn slippage_for_size(&self, side: Transection, quantity: f64) -> Option<f64>
pub fn slippage_for_size(&self, side: Transection, quantity: f64) -> Option<f64>
Slippage of filling quantity versus marking at mid: vwap - mid
for a buy, mid - vwap for a sell (so it is a cost when positive).
Trait Implementations§
Source§impl Clone for MarketDepth
impl Clone for MarketDepth
Source§fn clone(&self) -> MarketDepth
fn clone(&self) -> MarketDepth
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MarketDepth
impl Debug for MarketDepth
Source§impl PartialEq for MarketDepth
impl PartialEq for MarketDepth
impl StructuralPartialEq for MarketDepth
Auto Trait Implementations§
impl Freeze for MarketDepth
impl RefUnwindSafe for MarketDepth
impl Send for MarketDepth
impl Sync for MarketDepth
impl Unpin for MarketDepth
impl UnsafeUnpin for MarketDepth
impl UnwindSafe for MarketDepth
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