pub struct Level2 { /* private fields */ }Expand description
Represents the level 1 market data of the order book
Implementations§
Source§impl Level2
impl Level2
Sourcepub fn bid_levels(&self) -> &Vec<(Price, Quantity)>
pub fn bid_levels(&self) -> &Vec<(Price, Quantity)>
Get the bid side price levels, stored in a sorted vector from the best bid (highest price) to the worst bid (lowest price)
Sourcepub fn ask_levels(&self) -> &Vec<(Price, Quantity)>
pub fn ask_levels(&self) -> &Vec<(Price, Quantity)>
Get the ask side price levels, stored in a sorted vector from the best ask (lowest price) to the worst ask (highest price)
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 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 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