Leka
A low-latency C++20 price-time-priority limit order book and matching engine
▶ Replay viewer
Loading...
Searching...
No Matches
lob::PriceLevel Class Reference

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.
OrdergetHeadOrder () const
 Returns the first resting order, or nullptr when empty.
OrdergetTailOrder () 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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ PriceLevel()

lob::PriceLevel::PriceLevel ( Price price)
inlineexplicit

Creates an empty level for a single price.

Definition at line 28 of file price_level.hpp.

Member Function Documentation

◆ getPrice()

Price lob::PriceLevel::getPrice ( ) const
inline

Returns the level price.

Definition at line 31 of file price_level.hpp.

Referenced by lob::OrderBook::captureSnapshot().

◆ getHeadOrder()

Order * lob::PriceLevel::getHeadOrder ( ) const
inline

Returns the first resting order, or nullptr when empty.

Definition at line 33 of file price_level.hpp.

◆ getTailOrder()

Order * lob::PriceLevel::getTailOrder ( ) const
inline

Returns the last resting order, or nullptr when empty.

Definition at line 35 of file price_level.hpp.

◆ getOrderCount()

std::size_t lob::PriceLevel::getOrderCount ( ) const
inline

Returns the number of resting orders.

Definition at line 37 of file price_level.hpp.

Referenced by lob::OrderBook::captureSnapshot().

◆ getTotalQuantity()

Quantity lob::PriceLevel::getTotalQuantity ( ) const
inline

Returns the aggregate remaining quantity.

Definition at line 39 of file price_level.hpp.

Referenced by lob::OrderBook::captureSnapshot().

◆ addOrder()

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().

◆ removeOrder()

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().

◆ reduceTotalQuantity()

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().

◆ isEmpty()

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().


The documentation for this class was generated from the following files: