A C++ limit order book engine that replays historical NASDAQ market data: a byte-exact ITCH 5.0 protocol parser, an arena allocator, a robin-hood hash table for order lookups, and a price-level array order book.
- ITCH 5.0 message parsing (Add Order, Order Executed, Cancel, Delete, Replace, Stock Directory)
- Arena allocator for order objects, avoiding per-order heap allocation
- Robin-hood hash table (order ID -> order), stress-tested with 200,000 randomized operations
- Price-level array order book, stress-tested with 50,000 randomized operations
- Deterministic replay of ITCH files, with locate-code resolution so you can filter to a single symbol out of a multi-symbol feed
- Time-bucketed microstructure stats (spread, depth) that stay memory-bounded regardless of file size
- A spread/depth analysis script (
analysis/analyze_spread.py) for the CSV output, including market-hours-aware open/close comparison
mkdir build && cd build
cmake ..
make -j$(nproc)
cd build && ctest --output-on-failure
Download a free sample day from NASDAQ's public ITCH archive: https://emi.nasdaq.com/ITCH/Nasdaq%20ITCH/
Pick any dated .gz file, then:
gunzip <file>.NASDAQ_ITCH50.gz
A single day's file covers every NASDAQ symbol and typically contains hundreds of millions of messages.
./build/lob_replay --file <path_to_itch_file> --symbol AAPL --csv-output spread_timeseries.csv
Prices are in raw ITCH units (4 implied decimal places): $1.00 = 10000.
Adjust --min-price / --max-price / --tick-size if the default
$1-$2000 range at 1-cent ticks doesn't fit your target symbol.
python3 analysis/analyze_spread.py spread_timeseries.csv