59 [[nodiscard]]
friend auto operator==(
const Bbo&,
const Bbo&)
noexcept ->
bool =
default;
85 [[nodiscard]]
auto symbol() const noexcept -> const std::
string& {
return m_symbol; }
129 std::uint64_t old_reference_number,
130 std::uint64_t new_reference_number,
146 )
const -> std::optional<std::uint32_t>;
156 [[nodiscard]]
auto bbo() const ->
Bbo;
163 [[nodiscard]] auto
depth(
Side side, std::
size_t max_levels = 0) const
179 [[nodiscard]] auto
empty() const noexcept ->
bool {
return m_index.
empty(); }
183 static constexpr std::uint32_t NIL = 0xFFFFFFFFU;
189 std::uint32_t
price {0};
191 std::uint32_t next {NIL};
192 std::uint32_t prev {NIL};
197 std::uint32_t
price {0};
198 std::uint64_t total_shares {0};
199 std::uint32_t order_count {0};
200 std::uint32_t head {NIL};
201 std::uint32_t tail {NIL};
207 [[nodiscard]]
auto side_levels(
Side side)
noexcept -> std::vector<Level>&;
212 [[nodiscard]]
auto side_levels(
Side side)
const noexcept ->
const std::vector<Level>&;
217 auto allocate_node() -> std::uint32_t;
221 auto free_node(std::uint32_t node_index) -> void;
228 [[nodiscard]]
auto find_level(
Side side, std::uint32_t
price)
const -> std::uint32_t;
235 auto find_or_create_level(
Side side, std::uint32_t
price) -> std::uint32_t;
240 auto unlink_node(std::uint32_t node_index) -> void;
242 std::string m_symbol;
243 std::vector<OrderNode> m_pool;
244 std::uint32_t m_free_head {NIL};
245 std::vector<Level> m_bids;
246 std::vector<Level> m_asks;
A single-symbol, order-level (L3) limit order book with allocation-light internals.
auto execute_order(std::uint64_t reference_number, std::uint32_t shares) -> std::uint32_t
Removes shares from an order on execution (ITCH E/C), deleting it when fully filled.
auto replace_order(std::uint64_t old_reference_number, std::uint64_t new_reference_number, std::uint32_t shares, std::uint32_t price) -> void
Replaces an order with a new reference number, size, and price on the same side (ITCH U).
auto orders_at(Side side, std::uint32_t price) const -> std::vector< OrderView >
The resting orders at a given price on a side, in time priority.
auto delete_order(std::uint64_t reference_number) -> void
Deletes an order in its entirety (ITCH D).
auto level_count(Side side) const noexcept -> std::size_t
The number of active price levels on a side.
auto order_side(std::uint64_t reference_number) const -> std::optional< Side >
The side of a resting order, if present.
auto contains(std::uint64_t reference_number) const -> bool
Whether an order with the given reference number is resting.
auto empty() const noexcept -> bool
Whether the book has no resting orders on either side.
auto set_symbol(std::string symbol) -> void
Sets the stock symbol associated with this book.
auto order_price(std::uint64_t reference_number) const -> std::optional< std::uint32_t >
The raw limit price of a resting order, if present.
auto reduce_order(std::uint64_t reference_number, std::uint32_t shares) -> std::uint32_t
Removes shares from an order on a partial cancel (ITCH X), deleting it when it reaches zero.
auto symbol() const noexcept -> const std::string &
The stock symbol associated with this book (may be empty).
auto add_order(std::uint64_t reference_number, Side side, std::uint32_t shares, std::uint32_t price) -> void
Adds a new resting order to the book (ITCH A/F).
auto depth(Side side, std::size_t max_levels=0) const -> std::vector< DepthLevel >
Aggregated L2 depth for a side, best level first.
auto bbo() const -> Bbo
The current best bid and offer.
auto empty() const noexcept -> bool
Whether the map holds no keys.
std::string reference_number
Side
Which side of the book an order rests on.
Allocation-light, open-addressed hash map from order reference number to order-pool index.
Strongly typed, fixed-point price representation for ITCH price fields.
Best bid and offer of a single book.
StandardPrice ask_price
Best (lowest) ask price.
friend auto operator==(const Bbo &, const Bbo &) noexcept -> bool=default
Compares two BBO snapshots for equality of all fields.
std::uint64_t bid_shares
Shares at the best bid.
StandardPrice bid_price
Best (highest) bid price.
bool has_bid
Whether a bid side exists.
bool has_ask
Whether an ask side exists.
std::uint64_t ask_shares
Shares at the best ask.
Aggregated state of one price level, for L2 depth snapshots.
std::uint32_t order_count
Number of resting orders at the level.
std::uint64_t shares
Total displayed shares resting at the level.
StandardPrice price
The level's limit price.
A single resting order, for L3 order-level snapshots.
std::uint32_t shares
Shares still resting.
StandardPrice price
Limit price.
std::uint64_t reference_number
Exchange order reference number.