pub struct PriceLevel { /* private fields */ }Expand description
A lock-free implementation of a price level in a limit order book
Implementations§
Source§impl PriceLevel
impl PriceLevel
Sourcepub fn visible_quantity(&self) -> u64
pub fn visible_quantity(&self) -> u64
Get the visible quantity
Get the hidden quantity
Sourcepub fn total_quantity(&self) -> u64
pub fn total_quantity(&self) -> u64
Get the total quantity (visible + hidden)
Sourcepub fn order_count(&self) -> usize
pub fn order_count(&self) -> usize
Get the number of orders
Sourcepub fn add_order(&self, order: OrderType<()>) -> Arc<OrderType<()>>
pub fn add_order(&self, order: OrderType<()>) -> Arc<OrderType<()>>
Add an order to this price level
Sourcepub fn iter_orders(&self) -> Vec<Arc<OrderType<()>>>
pub fn iter_orders(&self) -> Vec<Arc<OrderType<()>>>
Creates an iterator over the orders in the price level.
Sourcepub fn match_order(
&self,
incoming_quantity: u64,
taker_order_id: OrderId,
transaction_id_generator: &UuidGenerator,
) -> MatchResult
pub fn match_order( &self, incoming_quantity: u64, taker_order_id: OrderId, transaction_id_generator: &UuidGenerator, ) -> MatchResult
Matches an incoming order against existing orders at this price level.
This function attempts to match the incoming order quantity against the orders present in the
OrderQueue. It iterates through the queue, matching orders until the incoming quantity is
fully filled or the queue is exhausted. Transactions are generated for each successful match,
and filled orders are removed from the queue. The function also updates the visible and hidden
quantity counters and records statistics for each execution.
§Arguments
incoming_quantity: The quantity of the incoming order to be matched.taker_order_id: The ID of the incoming order (the “taker” order).transaction_id_generator: An atomic counter used to generate unique transaction IDs.
§Returns
A MatchResult object containing the results of the matching operation, including a list of
generated transactions, the remaining unmatched quantity, a flag indicating whether the
incoming order was completely filled, and a list of IDs of orders that were completely filled
during the matching process.
Sourcepub fn snapshot(&self) -> PriceLevelSnapshot
pub fn snapshot(&self) -> PriceLevelSnapshot
Create a snapshot of the current price level state
Source§impl PriceLevel
impl PriceLevel
Sourcepub fn update_order(
&self,
update: OrderUpdate,
) -> Result<Option<Arc<OrderType<()>>>, PriceLevelError>
pub fn update_order( &self, update: OrderUpdate, ) -> Result<Option<Arc<OrderType<()>>>, PriceLevelError>
Apply an update to an existing order at this price level