pub struct LocalOrderBook { /* private fields */ }Expand description
Local view of an order book backed by sorted price levels.
Implementations§
Source§impl LocalOrderBook
impl LocalOrderBook
Sourcepub fn load_snapshot(
&mut self,
bids: &[(Price, Quantity)],
asks: &[(Price, Quantity)],
)
pub fn load_snapshot( &mut self, bids: &[(Price, Quantity)], asks: &[(Price, Quantity)], )
Reset the book with explicit bid/ask snapshots.
Sourcepub fn add_order(&mut self, side: Side, price: Price, quantity: Quantity)
pub fn add_order(&mut self, side: Side, price: Price, quantity: Quantity)
Insert or update a price level by accumulating quantity.
Sourcepub fn apply_delta(&mut self, side: Side, price: Price, quantity: Quantity)
pub fn apply_delta(&mut self, side: Side, price: Price, quantity: Quantity)
Overwrite a price level with the provided absolute quantity (removing when zero).
Sourcepub fn apply_deltas(
&mut self,
bids: &[(Price, Quantity)],
asks: &[(Price, Quantity)],
)
pub fn apply_deltas( &mut self, bids: &[(Price, Quantity)], asks: &[(Price, Quantity)], )
Apply a batch of bid/ask deltas atomically.
Sourcepub fn remove_order(&mut self, side: Side, price: Price, quantity: Quantity)
pub fn remove_order(&mut self, side: Side, price: Price, quantity: Quantity)
Remove quantity from a price level, deleting the level when depleted.
Sourcepub fn clear_level(&mut self, side: Side, price: Price)
pub fn clear_level(&mut self, side: Side, price: Price)
Remove an entire price level regardless of resting quantity.
Sourcepub fn bids(&self) -> impl Iterator<Item = (Price, Quantity)> + '_
pub fn bids(&self) -> impl Iterator<Item = (Price, Quantity)> + '_
Iterate bids in descending price order.
Sourcepub fn asks(&self) -> impl Iterator<Item = (Price, Quantity)> + '_
pub fn asks(&self) -> impl Iterator<Item = (Price, Quantity)> + '_
Iterate asks in ascending price order.
Sourcepub fn take_liquidity(
&mut self,
aggressive_side: Side,
quantity: Quantity,
) -> Vec<(Price, Quantity)>
pub fn take_liquidity( &mut self, aggressive_side: Side, quantity: Quantity, ) -> Vec<(Price, Quantity)>
Consume liquidity from the opposite side of an aggressive order.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true when either side of the book currently holds levels.
Sourcepub fn checksum(&self, depth: usize) -> u32
pub fn checksum(&self, depth: usize) -> u32
Compute a CRC32 checksum for the top N levels (Bybit/Binance compatibility).
Sourcepub fn bid_levels(&self, depth: usize) -> Vec<(Price, Quantity)>
pub fn bid_levels(&self, depth: usize) -> Vec<(Price, Quantity)>
Helper for generating owned bid levels up to the desired depth.
Sourcepub fn ask_levels(&self, depth: usize) -> Vec<(Price, Quantity)>
pub fn ask_levels(&self, depth: usize) -> Vec<(Price, Quantity)>
Helper for generating owned ask levels up to the desired depth.
Sourcepub fn volume_at_level(&self, side: Side, price: Price) -> Quantity
pub fn volume_at_level(&self, side: Side, price: Price) -> Quantity
Returns the total resting quantity at an exact price level.
Trait Implementations§
Source§impl Clone for LocalOrderBook
impl Clone for LocalOrderBook
Source§fn clone(&self) -> LocalOrderBook
fn clone(&self) -> LocalOrderBook
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more