21 : price(p), orders(), total_quantity(0) {}
25 return total_quantity;
34 [[nodiscard]]
bool isEmpty() const noexcept {
35 return orders.
empty();
40 return orders.
empty() ? nullptr : orders.
front();
44 return orders.
empty() ? nullptr : orders.
front();
50 auto it = orders.
begin();
51 while (it != orders.
end() && it->priority <= order->priority) {
55 if (it == orders.
end()) {
61 total_quantity += order->quantity;
66 total_quantity -= order->quantity;
72 total_quantity = total_quantity - old_quantity + new_quantity;
77 return price == other.price;
81 return price != other.price;
85 return price < other.price;
89 return price > other.price;
96 return a.price > b.price;
115 return a.price < b.price;
Intrusive doubly-linked list for zero-allocation order management.
constexpr pointer front() noexcept
Get front element.
constexpr iterator end() noexcept
constexpr void erase(T *node) noexcept
Remove specific element from list O(1) operation - no search required.
constexpr size_type size() const noexcept
Get number of elements.
constexpr bool empty() const noexcept
Check if list is empty.
constexpr iterator begin() noexcept
Iterators.
constexpr void push_back(T *node) noexcept
Add element to back (oldest order, FIFO time priority)
constexpr void insert_before(T *pos, T *node) noexcept
Insert element before given position O(1) operation.
#define SLICK_DETAIL_NAMESPACE_BEGIN
#define SLICK_DETAIL_NAMESPACE_END
int64_t Quantity
Quantity type - volume or size.
int64_t Price
Price type - fixed-point representation Example: For 4 decimal places, price = actual_price * 10000 T...
Comparator for sorting ask levels (ascending price)
constexpr bool operator()(Price a, Price b) const noexcept
constexpr bool operator()(Price a, const PriceLevelL3 &b) const noexcept
constexpr bool operator()(const PriceLevelL3 &a, const PriceLevelL3 &b) const noexcept
constexpr bool operator()(const PriceLevelL3 &a, Price b) const noexcept
Comparator for sorting bid levels (descending price)
constexpr bool operator()(Price a, const PriceLevelL3 &b) const noexcept
constexpr bool operator()(const PriceLevelL3 &a, const PriceLevelL3 &b) const noexcept
constexpr bool operator()(Price a, Price b) const noexcept
constexpr bool operator()(const PriceLevelL3 &a, Price b) const noexcept
Order structure for Level 3 orderbook Uses intrusive list design for zero-allocation order queues at ...
Price level for Level 3 orderbook (order-by-order) Maintains a queue of individual orders at this pri...
bool isEmpty() const noexcept
Check if this level is empty.
constexpr bool operator<(const PriceLevelL3 &other) const noexcept
void removeOrder(Order *order) noexcept
Remove order from the level.
Order * getBestOrder() noexcept
Get best order (first in queue)
IntrusiveList< Order > orders
constexpr bool operator!=(const PriceLevelL3 &other) const noexcept
std::size_t orderCount() const noexcept
Get number of orders at this level.
PriceLevelL3(Price p) noexcept
Quantity getTotalQuantity() const noexcept
Get total quantity at this level.
void insertOrder(Order *order) noexcept
Insert order maintaining priority order.
constexpr bool operator>(const PriceLevelL3 &other) const noexcept
constexpr bool operator==(const PriceLevelL3 &other) const noexcept
Comparison operators for sorting by price.
const Order * getBestOrder() const noexcept
void updateOrderQuantity(Quantity old_quantity, Quantity new_quantity) noexcept
Update order quantity (for modify operations)