Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flashbook

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.

What's implemented

  • 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

Build

mkdir build && cd build
cmake ..
make -j$(nproc)

Test

cd build && ctest --output-on-failure

Getting market data

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.

Run against historical data

./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.

Analyze the results

python3 analysis/analyze_spread.py spread_timeseries.csv

About

Limit order book replaying historical NASDAQ ITCH data using arena allocator, robin-hood hash table, price-level arrays

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages