A high-performance simulated stock exchange written in C++17. It combines a work-stealing thread pool with per-symbol limit order books to process buy and sell orders across multiple trading symbols concurrently. (This project combines my previous order-book and thread-pool into one)
- Each symbol (e.g. AAPL, TSLA) gets its own order book with FIFO price-time priority matching
- A thread pool distributes order processing across CPU cores, automatically stealing work from busy threads to keep all cores utilized
- Supports market and limit orders with partial fills
Requirements: g++ with C++17 support, make
make # compile
make run # compile and run benchmarks
make clean # remove build artifactsorder_book.h / order_book.cpp — limit order book (LOB) per symbol
thread_pool.h / thread_pool.cpp — work-stealing thread pool
exchange_engine.h / exchange_engine.cpp — ties the two together
main.cpp — demo and benchmarks
Makefile
Tested on an 8-core machine:
| Symbols | Orders | Throughput | Avg Latency |
|---|---|---|---|
| 4 | 200K | 456K/sec | 332ns |
| 8 | 200K | 403K/sec | 395ns |
| 16 | 200K | 418K/sec | 398ns |