NanoMatch
NanoMatch is a high-performance limit order book and matching engine built in modern C++20. It simulates a financial exchange's core operations, processing buy/sell orders with price-time priority matching at millions of operations per second.
01 / Overview
- 01C++20
- 02CMake 3.20+
- 03Google Test 1.17
- 04GitHub Actions CI/CD
- 05AddressSanitizer
- 06UBSan
Problem
Financial exchanges require ultra-low-latency order matching. Understanding how matching engines work at the systems level demands building one from scratch with real performance constraints.
Solution Overview
- Implemented price-time priority (FIFO) matching with support for Limit, Market, IOC, and FOK orders
- Designed O(1) order cancellation and modification using hash map indexing
- Built a custom pool allocator to eliminate heap allocation overhead on the hot path
- Added multi-instrument support with independent order books per symbol
02 / Evidence
Proof & Verification
- Throughput: 1M+ orders/second (single-thread, synthetic benchmark)
- Comprehensive test suite with p50/p99 latency benchmarks
- All 60+ unit tests across 18 test suites passed
- CI: ASan, UBSan, cppcheck, clang-format on every push
03 / Methods
Build
Tech Stack
- C++20
- CMake 3.20+
- Google Test 1.17
- GitHub Actions CI/CD
- AddressSanitizer
- UBSan
- Price-time priority (FIFO) matching algorithm
- 4 order types: Limit, Market, IOC, Fill-or-Kill
- O(1) order cancellation/modification via hash map
- Custom pool allocator eliminating heap allocation overhead
Secure
- AddressSanitizer and UndefinedBehaviorSanitizer in CI
- 60+ unit tests across 18 test suites
- cppcheck static analysis on every push
- No external runtime dependencies