|
ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
|
A single-symbol, order-level (L3) limit order book with allocation-light internals. More...
#include <l3_book.hpp>
Public Member Functions | |
| L3Book (std::string symbol={}) | |
| Constructs a book, optionally tagged with its stock symbol. | |
| auto | set_symbol (std::string symbol) -> void |
| Sets the stock symbol associated with this book. | |
| 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 | 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 | 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 | delete_order (std::uint64_t reference_number) -> void |
Deletes an order in its entirety (ITCH D). | |
| 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 | contains (std::uint64_t reference_number) const -> bool |
| Whether an order with the given reference number is resting. | |
| 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 | order_side (std::uint64_t reference_number) const -> std::optional< Side > |
| The side of a resting order, if present. | |
| auto | bbo () const -> Bbo |
| The current best bid and offer. | |
| auto | depth (Side side, std::size_t max_levels=0) const -> std::vector< DepthLevel > |
| Aggregated L2 depth for a side, best level first. | |
| 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 | level_count (Side side) const noexcept -> std::size_t |
| The number of active price levels on a side. | |
| auto | empty () const noexcept -> bool |
| Whether the book has no resting orders on either side. | |
A single-symbol, order-level (L3) limit order book with allocation-light internals.
Unlike the original LimitOrderBook, which stored each order in a std::shared_ptr inside a std::list and each price level in a std::map, this engine holds orders in a reusable object pool (a flat vector with a free list) linked into intrusive FIFO queues, and keeps each side's price levels in a flat, sorted vector. There is no per-order heap allocation, no atomic refcount, and no per-level node allocation on the hot path; order lookup by reference number is O(1) and the best bid/offer is the front of a ladder.
Definition at line 72 of file l3_book.hpp.
|
explicit |
Constructs a book, optionally tagged with its stock symbol.
| symbol | The ticker symbol to associate with the book (may be empty). |
Definition at line 8 of file l3_book.cpp.
|
inline |
Sets the stock symbol associated with this book.
| symbol | The ticker symbol to associate with the book. |
Definition at line 81 of file l3_book.hpp.
References symbol().
|
inlinenoexcept |
The stock symbol associated with this book (may be empty).
Definition at line 85 of file l3_book.hpp.
Referenced by set_symbol(), and itch::book::BookManager::symbol_for_locate().
| auto itch::book::L3Book::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).
| reference_number | Exchange order reference number identifying the new order. |
| side | The side of the book the order rests on. |
| shares | The number of shares in the new order. |
| price | The raw (unscaled) limit price of the new order. |
Definition at line 93 of file l3_book.cpp.
References itch::book::OrderIndex::NPOS, price, reference_number, shares, and side.
| auto itch::book::L3Book::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.
Returns the shares actually removed.
| reference_number | Exchange order reference number of the order being executed against. |
| shares | The number of shares to remove from the order. |
shares if the order does not have that many resting). Definition at line 150 of file l3_book.cpp.
References itch::book::OrderIndex::NPOS, reference_number, and shares.
| auto itch::book::L3Book::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.
Returns the shares actually removed.
| reference_number | Exchange order reference number of the order being reduced. |
| shares | The number of shares to remove from the order. |
shares if the order does not have that many resting). Definition at line 173 of file l3_book.cpp.
References reference_number, and shares.
| auto itch::book::L3Book::delete_order | ( | std::uint64_t | reference_number | ) | -> void |
Deletes an order in its entirety (ITCH D).
| reference_number | Exchange order reference number of the order to delete. |
Definition at line 178 of file l3_book.cpp.
References itch::book::OrderIndex::NPOS, and reference_number.
| auto itch::book::L3Book::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).
| old_reference_number | Exchange order reference number of the order being replaced. |
| new_reference_number | Exchange order reference number assigned to the replacement order. |
| shares | The number of shares in the replacement order. |
| price | The raw (unscaled) limit price of the replacement order. |
Definition at line 188 of file l3_book.cpp.
References itch::book::OrderIndex::NPOS, price, shares, and side.
| auto itch::book::L3Book::contains | ( | std::uint64_t | reference_number | ) | const -> bool |
Whether an order with the given reference number is resting.
| reference_number | Exchange order reference number to look up. |
reference_number is resting, false otherwise. Definition at line 203 of file l3_book.cpp.
References reference_number.
| auto itch::book::L3Book::order_price | ( | std::uint64_t | reference_number | ) | const -> std::optional<std::uint32_t> |
The raw limit price of a resting order, if present.
| reference_number | Exchange order reference number to look up. |
std::nullopt if no such order is resting. Definition at line 207 of file l3_book.cpp.
References itch::book::OrderIndex::NPOS, and reference_number.
| auto itch::book::L3Book::order_side | ( | std::uint64_t | reference_number | ) | const -> std::optional<Side> |
The side of a resting order, if present.
| reference_number | Exchange order reference number to look up. |
std::nullopt if no such order is resting. Definition at line 215 of file l3_book.cpp.
References itch::book::OrderIndex::NPOS, and reference_number.
| auto itch::book::L3Book::bbo | ( | ) | const -> Bbo |
The current best bid and offer.
Definition at line 223 of file l3_book.cpp.
References itch::book::Bbo::has_bid.
| auto itch::book::L3Book::depth | ( | Side | side, |
| std::size_t | max_levels = 0 |
||
| ) | const -> std::vector<DepthLevel> |
Aggregated L2 depth for a side, best level first.
| side | The side to report. |
| max_levels | The maximum number of levels to return (0 == all). |
Definition at line 238 of file l3_book.cpp.
References itch::book::DepthLevel::price, and side.
| auto itch::book::L3Book::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.
| side | The side to query. |
| price | The raw (unscaled) limit price to query. |
price on side, oldest first. Definition at line 253 of file l3_book.cpp.
References price, itch::book::OrderView::reference_number, and side.
|
noexcept |
The number of active price levels on a side.
| side | The side to query. |
side. Definition at line 273 of file l3_book.cpp.
References side.
|
inlinenoexcept |
Whether the book has no resting orders on either side.
Definition at line 179 of file l3_book.hpp.
References itch::book::OrderIndex::empty().