ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
itch::LimitOrderBook Class Reference

Manages the state of a limit order book for a specific financial instrument. More...

#include <order_book.hpp>

Public Types

using BidMap = std::map< uint32_t, PriceLevel, std::greater< uint32_t > >
 
using AskMap = std::map< uint32_t, PriceLevel, std::less< uint32_t > >
 

Public Member Functions

 LimitOrderBook (const std::string &stock_symbol)
 Constructs an order book scoped to a single stock symbol.
 
auto process (const Message &message) -> void
 Dispatches and processes a generic ITCH message.
 
auto print (std::ostream &out, unsigned int delay_ms=0) const -> void
 Visualizes the current state of the order book to an output stream.
 
auto get_bids () const -> const BidMap &
 The map of active Bids.
 
auto get_asks () const -> const AskMap &
 The map of active Asks.
 

Public Attributes

const std::set< char > book_messages {'A', 'F', 'E', 'C', 'X', 'D', 'U'}
 Set of message type characters that affect the book state.
 

Detailed Description

Manages the state of a limit order book for a specific financial instrument.

The LimitOrderBook ingests raw Nasdaq ITCH 5.0 messages and reconstructs the full depth of market. It supports standard order lifecycle events including addition, execution, cancellation, deletion, and replacement.

Note
This implementation uses std::map for price levels to ensure keys (prices) are always sorted, allowing for O(log n) insertion and deletion of price levels, and O(1) access to the best bid/ask.

Definition at line 90 of file order_book.hpp.

Member Typedef Documentation

◆ BidMap

using itch::LimitOrderBook::BidMap = std::map<uint32_t, PriceLevel, std::greater<uint32_t> >

Definition at line 116 of file order_book.hpp.

◆ AskMap

using itch::LimitOrderBook::AskMap = std::map<uint32_t, PriceLevel, std::less<uint32_t> >

Definition at line 117 of file order_book.hpp.

Constructor & Destructor Documentation

◆ LimitOrderBook()

itch::LimitOrderBook::LimitOrderBook ( const std::string &  stock_symbol)
inline

Constructs an order book scoped to a single stock symbol.

Parameters
stock_symbolThe symbol of the instrument this book tracks; only messages for this symbol affect the book state.

Definition at line 96 of file order_book.hpp.

Member Function Documentation

◆ process()

auto itch::LimitOrderBook::process ( const Message message) -> void

Dispatches and processes a generic ITCH message.

Identifies the specific type within the Message variant and routes it to the appropriate internal handler to update the book state.

Parameters
messageThe parsed ITCH message variant.

Definition at line 22 of file order_book.cpp.

◆ print()

auto itch::LimitOrderBook::print ( std::ostream &  out,
unsigned int  delay_ms = 0 
) const -> void

Visualizes the current state of the order book to an output stream.

Prints the best Ask and Bid levels formatted in a table.

Parameters
outThe output stream (e.g., std::cout) to write to.
delay_msOptional delay in milliseconds between printing each line. Useful for slowing down output during debugging or replays to create an animation effect. Defaults to 0 (no delay).

Definition at line 34 of file order_book.cpp.

References itch::make_price(), and side.

◆ get_bids()

auto itch::LimitOrderBook::get_bids ( ) const -> const BidMap&
inline

The map of active Bids.

Returns
A reference to the map of active Bids, sorted descending by price.

Definition at line 122 of file order_book.hpp.

◆ get_asks()

auto itch::LimitOrderBook::get_asks ( ) const -> const AskMap&
inline

The map of active Asks.

Returns
A reference to the map of active Asks, sorted ascending by price.

Definition at line 127 of file order_book.hpp.

Member Data Documentation

◆ book_messages

const std::set<char> itch::LimitOrderBook::book_messages {'A', 'F', 'E', 'C', 'X', 'D', 'U'}

Set of message type characters that affect the book state.

Definition at line 130 of file order_book.hpp.


The documentation for this class was generated from the following files: