|
Leka
A low-latency C++20 price-time-priority limit order book and matching engine
|
Maintains FIFO resting orders at one price. More...
#include <price_level.hpp>
Public Member Functions | |
| PriceLevel (Price price) | |
| Creates an empty level for a single price. | |
| Price | getPrice () const |
| Returns the level price. | |
| Order * | getHeadOrder () const |
| Returns the first resting order, or nullptr when empty. | |
| Order * | getTailOrder () const |
| Returns the last resting order, or nullptr when empty. | |
| std::size_t | getOrderCount () const |
| Returns the number of resting orders. | |
| Quantity | getTotalQuantity () const |
| Returns the aggregate remaining quantity. | |
| void | addOrder (Order *order) |
| Appends an order to the FIFO and updates aggregate state. | |
| void | removeOrder (Order *order) |
| Unlinks an order and updates aggregate state. | |
| void | reduceTotalQuantity (Quantity quantity) |
| Decreases aggregate quantity after a partial execution. | |
| bool | isEmpty () const |
| Returns true when no orders are resting at this price. | |
Maintains FIFO resting orders at one price.
Orders are linked intrusively, so appending and removing a known order are constant-time operations. The level also tracks order count and aggregate remaining quantity.
Definition at line 16 of file price_level.hpp.
|
inlineexplicit |
Creates an empty level for a single price.
Definition at line 28 of file price_level.hpp.
|
inline |
Returns the level price.
Definition at line 31 of file price_level.hpp.
Referenced by lob::OrderBook::captureSnapshot().
|
inline |
Returns the first resting order, or nullptr when empty.
Definition at line 33 of file price_level.hpp.
|
inline |
Returns the last resting order, or nullptr when empty.
Definition at line 35 of file price_level.hpp.
|
inline |
Returns the number of resting orders.
Definition at line 37 of file price_level.hpp.
Referenced by lob::OrderBook::captureSnapshot().
|
inline |
Returns the aggregate remaining quantity.
Definition at line 39 of file price_level.hpp.
Referenced by lob::OrderBook::captureSnapshot().
| void lob::PriceLevel::addOrder | ( | Order * | order | ) |
Appends an order to the FIFO and updates aggregate state.
Appends an eligible order and updates FIFO and aggregate state.
Definition at line 9 of file price_level.cpp.
References lob::Order::getPrice(), lob::Order::getPriceLevel(), lob::Quantity::getQuantity(), lob::Order::getRemainingQuantity(), lob::Order::isFullyFilled(), lob::Order::setNextOrder(), lob::Order::setPreviousOrder(), and lob::Order::setPriceLevel().
| void lob::PriceLevel::removeOrder | ( | Order * | order | ) |
Unlinks an order and updates aggregate state.
Unlinks an order in constant time while it is still alive.
Definition at line 41 of file price_level.cpp.
References lob::Order::getNextOrder(), lob::Order::getPreviousOrder(), lob::Order::getPriceLevel(), lob::Quantity::getQuantity(), lob::Order::getRemainingQuantity(), lob::Order::setNextOrder(), lob::Order::setPreviousOrder(), and lob::Order::setPriceLevel().
Referenced by lob::OrderBook::removeOrder().
| void lob::PriceLevel::reduceTotalQuantity | ( | Quantity | quantity | ) |
Decreases aggregate quantity after a partial execution.
Applies a partial execution to the aggregate quantity.
Definition at line 70 of file price_level.cpp.
References lob::Quantity::getQuantity().
Referenced by lob::OrderBook::reduceOrder().
| bool lob::PriceLevel::isEmpty | ( | ) | const |
Returns true when no orders are resting at this price.
Definition at line 78 of file price_level.cpp.
Referenced by lob::OrderBook::removeOrder().