Trading.OrderBook.PriceLevel (trading v0.1.0)
Represents a price level in the order book with efficient order management.
Summary
Functions
Adds an order to the price level.
Checks if the price level is empty.
Creates a new price level.
Gets the first order in the level (price-time priority).
Removes and returns the first order.
Removes an order from the price level.
Converts the price level to a list of orders.
Updates an order in the price level.
Types
@type t() :: %Trading.OrderBook.PriceLevel{ order_count: non_neg_integer(), orders: :queue.queue(Trading.Order.t()), price: float(), side: :buy | :sell, total_volume: non_neg_integer() }
Functions
@spec add_order(t(), Trading.Order.t()) :: t()
Adds an order to the price level.
Checks if the price level is empty.
Creates a new price level.
@spec peek_first(t()) :: Trading.Order.t() | nil
Gets the first order in the level (price-time priority).
@spec pop_first(t()) :: {t(), Trading.Order.t() | nil}
Removes and returns the first order.
@spec remove_order(t(), String.t()) :: {t(), Trading.Order.t() | nil}
Removes an order from the price level.
@spec to_list(t()) :: [Trading.Order.t()]
Converts the price level to a list of orders.
@spec update_order(t(), String.t(), (Trading.Order.t() -> Trading.Order.t())) :: {t(), Trading.Order.t() | nil}
Updates an order in the price level.