35 uint16_t idx = 0, uint8_t flags = 0, uint64_t seq = 0) noexcept
36 : timestamp(ts), seq_num(seq), price(p), quantity(q), symbol(sym),
37 level_index(idx), num_orders(order_count), change_flags(flags), side(s) {}
40 [[nodiscard]]
constexpr bool isDelete() const noexcept {
55 [[nodiscard]]
constexpr bool isTopN(uint16_t n)
const noexcept {
56 return level_index < n;
84 uint16_t idx = 0, uint64_t prio = 0, uint8_t flags = 0, uint64_t seq = 0) noexcept
85 : timestamp(ts), seq_num(seq), order_id(
id), price(p), quantity(q), old_price(op), old_qty(oq), symbol(sym),
86 price_level_index(idx), priority(prio), side(s), change_flags(flags) {}
89 [[nodiscard]]
constexpr bool isDelete() const noexcept {
104 [[nodiscard]]
constexpr bool isTopN(uint16_t n)
const noexcept {
105 return price_level_index < n;
125 Trade() noexcept : symbol(0), price(0), quantity(0), timestamp(0),
126 aggressive_order_id(0), passive_order_id(0),
127 aggressor_side(
Side::Buy), change_flags(0) {}
130 OrderId passive = 0,
OrderId aggressive = 0, uint8_t flags = 0) noexcept
131 : symbol(sym), price(p), quantity(q), timestamp(ts),
132 aggressive_order_id(aggressive), passive_order_id(passive),
133 aggressor_side(aggressor), change_flags(flags) {}
149 std::array<uint8_t, 2> change_flags {0, 0};
152 : symbol(0), best_bid(0), bid_quantity(0), best_ask(0), ask_quantity(0), timestamp(0) {}
155 : symbol(sym), best_bid(bid), bid_quantity(bid_qty), best_ask(ask), ask_quantity(ask_qty), timestamp(ts) {}
159 return (best_ask > best_bid) ? (best_ask - best_bid) : 0;
164 return (best_bid + best_ask) / 2;
169 return best_bid >= best_ask && best_bid > 0 && best_ask > 0;
173 [[nodiscard]]
bool hasBid() const noexcept {
174 return best_bid > 0 && bid_quantity > 0;
178 [[nodiscard]]
bool hasAsk() const noexcept {
179 return best_ask > 0 && ask_quantity > 0;
184 return hasBid() && hasAsk();
#define SLICK_NAMESPACE_END
#define SLICK_NAMESPACE_BEGIN
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...
uint64_t OrderId
Unique order identifier.
Side
Order side - using enum for easy array indexing.
ChangeFlag
Change flags for price level and order updates (regular enum for bitwise operations)
uint16_t SymbolId
Symbol identifier - can be hash or sequential ID.
uint64_t Timestamp
Timestamp in nanoseconds since epoch.
Level 3 order update event Note: quantity = 0 implies the order should be deleted.
constexpr bool quantityChanged() const noexcept
Check if quantity changed.
uint16_t price_level_index
constexpr bool priceChanged() const noexcept
Check if price changed (order was added or moved to different price)
constexpr bool isLastInBatch() const noexcept
Check if this is the last update in a batch.
constexpr bool isDelete() const noexcept
Check if this is a delete action.
constexpr bool isTopN(uint16_t n) const noexcept
Check if this order's price level is in the top N levels.
OrderUpdate() noexcept=default
Level 2 price level update event Note: quantity = 0 implies the price level should be deleted.
constexpr bool priceChanged() const noexcept
Check if price changed (level was added or moved)
PriceLevelUpdate() noexcept=default
constexpr bool quantityChanged() const noexcept
Check if quantity changed.
constexpr bool isTopN(uint16_t n) const noexcept
Check if this update affects the top N levels.
constexpr bool isDelete() const noexcept
Check if this is a delete action.
constexpr bool isLastInBatch() const noexcept
Check if this is the last update in a batch.
Top-of-book snapshot - best bid and ask.
bool hasBid() const noexcept
Check if book has valid bid.
bool isValid() const noexcept
Check if book has both valid bid and ask.
bool hasAsk() const noexcept
Check if book has valid ask.
Price spread() const noexcept
Calculate spread.
bool isCrossed() const noexcept
Check if book is crossed (bid >= ask, should not happen in normal conditions)
Price midPrice() const noexcept
Calculate mid price.
TopOfBook(SymbolId sym, Price bid, Quantity bid_qty, Price ask, Quantity ask_qty, Timestamp ts) noexcept
Trade event - represents an executed trade.
Trade(SymbolId sym, Price p, Quantity q, Timestamp ts, Side aggressor, OrderId passive=0, OrderId aggressive=0, uint8_t flags=0) noexcept
OrderId aggressive_order_id
constexpr bool isLastInBatch() const noexcept
Check if this is the last update in a batch.