pub struct OrderBook<const PRICE_LEVELS_INITIAL_CAPACITY: usize = 2048> { /* private fields */ }Expand description
Order book that manages all kinds of orders and levels
Implementations§
Source§impl OrderBook
impl OrderBook
Sourcepub fn best_bid_price(&self) -> Option<Price>
pub fn best_bid_price(&self) -> Option<Price>
Get the best bid price, if exists
Sourcepub fn best_ask_price(&self) -> Option<Price>
pub fn best_ask_price(&self) -> Option<Price>
Get the best ask price, if exists
Sourcepub fn best_bid_size(&self) -> Option<Quantity>
pub fn best_bid_size(&self) -> Option<Quantity>
Get the best bid size, if exists
Sourcepub fn best_ask_size(&self) -> Option<Quantity>
pub fn best_ask_size(&self) -> Option<Quantity>
Get the best ask size, if exists
Sourcepub fn is_side_empty(&self, side: Side) -> bool
pub fn is_side_empty(&self, side: Side) -> bool
Check if the side is empty
Sourcepub fn has_crossable_order(&self, taker_side: Side, limit_price: Price) -> bool
pub fn has_crossable_order(&self, taker_side: Side, limit_price: Price) -> bool
Check if there is a crossable order at the given limit price
Sourcepub fn micro_price(&self) -> Option<f64>
pub fn micro_price(&self) -> Option<f64>
Calculate the micro price, which weights the best bid and ask by the opposite side’s liquidity
Sourcepub fn bid_size(&self, n_levels: usize) -> Quantity
pub fn bid_size(&self, n_levels: usize) -> Quantity
Get the bid size for the first N price levels
Sourcepub fn ask_size(&self, n_levels: usize) -> Quantity
pub fn ask_size(&self, n_levels: usize) -> Quantity
Get the ask size for the first N price levels
Sourcepub fn is_thin_book(&self, threshold: Quantity, n_levels: usize) -> bool
pub fn is_thin_book(&self, threshold: Quantity, n_levels: usize) -> bool
Check if the order book is thin at the given threshold and number of levels
Sourcepub fn order_book_imbalance(&self, n_levels: usize) -> f64
pub fn order_book_imbalance(&self, n_levels: usize) -> f64
Calculate the order book imbalance ratio for the top N levels
Sourcepub fn depth_statistics(&self, side: Side, n_levels: usize) -> DepthStatistics
pub fn depth_statistics(&self, side: Side, n_levels: usize) -> DepthStatistics
Compute the depth statistics of price levels (0 n_levels means all levels)
Sourcepub fn buy_sell_pressure(&self) -> (Quantity, Quantity)
pub fn buy_sell_pressure(&self) -> (Quantity, Quantity)
Compute the buy and sell pressure of the order book
Sourcepub fn price_at_depth(&self, side: Side, depth: Quantity) -> Option<Price>
pub fn price_at_depth(&self, side: Side, depth: Quantity) -> Option<Price>
Find the price where cumulative depth reaches the target quantity
Return None if the target depth cannot be reached
Sourcepub fn vwap(&self, taker_side: Side, quantity: Quantity) -> Option<f64>
pub fn vwap(&self, taker_side: Side, quantity: Quantity) -> Option<f64>
Calculate the volume-weighted average price (VWAP) for a given quantity
Return None if the given quantity is zero or cannot be filled
Sourcepub fn market_impact(
&self,
taker_side: Side,
quantity: Quantity,
) -> MarketImpact
pub fn market_impact( &self, taker_side: Side, quantity: Quantity, ) -> MarketImpact
Compute the market impact of a market order
Source§impl OrderBook
impl OrderBook
Sourcepub fn execute(&mut self, cmd: &Command) -> CommandOutcome
pub fn execute(&mut self, cmd: &Command) -> CommandOutcome
Execute a command against the order book Returns the execution report for the command
Source§impl OrderBook
impl OrderBook
Sourcepub fn last_sequence_number(&self) -> Option<SequenceNumber>
pub fn last_sequence_number(&self) -> Option<SequenceNumber>
Get the last sequence number of the order book, None if no command has been processed yet.
Sourcepub fn last_seen_timestamp(&self) -> Option<Timestamp>
pub fn last_seen_timestamp(&self) -> Option<Timestamp>
Get the last seen timestamp of the order book, None if no command has been processed yet.
Sourcepub fn last_trade_price(&self) -> Option<Price>
pub fn last_trade_price(&self) -> Option<Price>
Get the last trade price, None if no trade has occurred yet
Sourcepub fn pegged(&self) -> &PeggedBook
pub fn pegged(&self) -> &PeggedBook
Get the pegged order book