58 [[nodiscard]]
SymbolId symbol() const noexcept {
return symbol_; }
71 uint64_t seq_num = 0,
bool is_last_in_batch =
true);
99 [[nodiscard]] const detail::PriceLevelL2* getBestAsk() const noexcept;
103 [[nodiscard]]
TopOfBook getTopOfBook() const noexcept;
109 [[nodiscard]] std::vector<detail::PriceLevelL2> getLevels(
Side side, std::
size_t depth = 0) const;
115 [[nodiscard]] const detail::PriceLevelL2* getLevel(
Side side,
Price price) const noexcept;
121 [[nodiscard]] const detail::PriceLevelL2* getLevelByIndex(
Side side, uint16_t index) const noexcept;
126 [[nodiscard]] std::
size_t levelCount(
Side side) const noexcept;
131 [[nodiscard]]
bool isEmpty(
Side side) const noexcept;
135 [[nodiscard]]
bool isEmpty() const noexcept;
139 observers_.addObserver(std::move(observer));
143 return observers_.removeObserver(observer);
147 observers_.clearObservers();
151 return observers_.observerCount();
157 return last_seq_num_;
170 void notifyTopOfBookIfChanged(
Timestamp timestamp);
173 std::array<detail::LevelContainer, SideCount>
sides_;
187#ifdef SLICK_ORDERBOOK_HEADER_ONLY
Base interface for orderbook observers Observers receive callbacks for orderbook events.
Observer manager for notifying multiple observers Uses type erasure to support both concept-based and...
Level 2 OrderBook - aggregated price levels.
ObserverManager observers_
detail::PriceLevelL2 cached_best_ask_
std::atomic< uint64_t > tob_seq_
virtual ~OrderBookL2()=default
Destructor.
void clearObservers() noexcept
std::size_t observerCount() const noexcept
OrderBookL2(const OrderBookL2 &)=delete
OrderBookL2 & operator=(const OrderBookL2 &)=delete
uint64_t getLastSeqNum() const noexcept
Get last processed sequence number.
detail::PriceLevelL2 cached_best_bid_
bool removeObserver(const std::shared_ptr< IOrderBookObserver > &observer)
std::array< detail::LevelContainer, SideCount > sides_
#define SLICK_NAMESPACE_END
#define SLICK_DLL_INTERFACE_WARNINGS_PUSH
#define SLICK_CACHE_ALIGNED
#define SLICK_NAMESPACE_BEGIN
#define SLICK_DLL_INTERFACE_WARNINGS_POP
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...
Side
Order side - using enum for easy array indexing.
constexpr uint16_t INVALID_INDEX
uint16_t SymbolId
Symbol identifier - can be hash or sequential ID.
uint64_t Timestamp
Timestamp in nanoseconds since epoch.
Top-of-book snapshot - best bid and ask.
Price level for Level 2 orderbook (aggregated) Stores total quantity at a specific price point.