Slick OrderBook 1.1.0
High-Performance C++23 OrderBook Library
Loading...
Searching...
No Matches
order.hpp
Go to the documentation of this file.
1// Copyright 2026 Slick Quant
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
8
10
15 OrderId order_id; // Unique order identifier
16 Price price; // Order price
17 Quantity quantity; // Order quantity
18 Side side; // Buy or Sell
19 Timestamp timestamp; // Order timestamp
20 uint64_t priority; // Priority for sorting at same price level (lower = higher priority)
21
22 // Intrusive list pointers (managed by IntrusiveList)
25
27 Order(OrderId id, Price p, Quantity qty, Side s, Timestamp ts, uint64_t prio) noexcept
28 : order_id(id),
29 price(p),
30 quantity(qty),
31 side(s),
32 timestamp(ts),
33 priority(prio),
34 prev(nullptr),
35 next(nullptr) {
36 }
37
39 Order(OrderId id, Price p, Quantity qty, Side s, Timestamp ts) noexcept
40 : Order(id, p, qty, s, ts, ts) { // Use timestamp as priority by default
41 }
42
44 Order() noexcept
45 : order_id(0),
46 price(0),
47 quantity(0),
48 side(Side::Buy),
49 timestamp(0),
50 priority(0),
51 prev(nullptr),
52 next(nullptr) {
53 }
54
57 [[nodiscard]] bool operator<(const Order& other) const noexcept {
58 return priority < other.priority;
59 }
60
61 [[nodiscard]] bool operator>(const Order& other) const noexcept {
62 return priority > other.priority;
63 }
64};
65
#define SLICK_DETAIL_NAMESPACE_BEGIN
Definition config.hpp:129
#define SLICK_DETAIL_NAMESPACE_END
Definition config.hpp:130
#define SLICK_CACHE_ALIGNED
Definition config.hpp:123
int64_t Quantity
Quantity type - volume or size.
Definition types.hpp:21
int64_t Price
Price type - fixed-point representation Example: For 4 decimal places, price = actual_price * 10000 T...
Definition types.hpp:18
uint64_t OrderId
Unique order identifier.
Definition types.hpp:24
Side
Order side - using enum for easy array indexing.
Definition types.hpp:35
uint64_t Timestamp
Timestamp in nanoseconds since epoch.
Definition types.hpp:30
Order structure for Level 3 orderbook Uses intrusive list design for zero-allocation order queues at ...
Definition order.hpp:14
bool operator<(const Order &other) const noexcept
Comparison operator for priority-based sorting Lower priority value = higher priority in queue.
Definition order.hpp:57
Order(OrderId id, Price p, Quantity qty, Side s, Timestamp ts) noexcept
Constructor with timestamp as priority (common case)
Definition order.hpp:39
bool operator>(const Order &other) const noexcept
Definition order.hpp:61
Order(OrderId id, Price p, Quantity qty, Side s, Timestamp ts, uint64_t prio) noexcept
Constructor with all fields.
Definition order.hpp:27
Order() noexcept
Default constructor (for pool allocation)
Definition order.hpp:44