Deterministic FIFO limit order book and matching engine core — header-only
C++20, measured at up to ~105M orders/sec batched on a cache-resident book
(25M at 100k live orders, 14M at 1M; 44M on the mixed workload), and 120M orders/sec
aggregate across 8 shards on a mixed workload (see spec/BENCH.md).
Single-writer book per symbol, commands in, monotonically sequenced events out.
All I/O hangs off the Sink concept; there is no networking, persistence, or
clock dependence in the core. Zero dependencies.
#include <matcher/matcher.hpp>matcher::OrderBook book(matcher::BookConfig{});
matcher::VecSink sink;
book.apply(matcher::Command::new_limit(1, matcher::Side::Ask, 100, 10,
matcher::Tif::Gtc), sink);
book.apply(matcher::Command::new_limit(2, matcher::Side::Bid, 100, 4,
matcher::Tif::Gtc), sink);
// order 2 filled 4 @100 against order 1 and closed; order 1 keeps 6 resting.Header-only, C++20 — add include/ to your include path, or via CMake:
add_subdirectory(matcher-cpp)
target_link_libraries(your_target PRIVATE matcher)
# or: cmake --install build, then find_package(matcher) → matcher::matcher- Limit + Market orders, New / Cancel / Replace
- GTC, IOC, FOK, Post-Only
- FIFO price-time priority, maker-price execution, partial fills, sweeps
- Pooled orders, intrusive FIFO price levels, bitmap ladder index with
std::mapfallback for unbounded prices - Enum-dispatched index — no virtual dispatch on the hot path
- Thin multi-symbol
Enginerouter - Deterministic event streams — verified byte-identically against the shared
golden vector corpus (
vectors/)
include/matcher/ headers (book, engine, types, sink, detail/internals)
tests/golden.cpp golden vector runner
bench/ matcherbench harness
vectors/ shared golden corpus (spec repo: github.com/abhijitkrm/matcher)
spec/ semantics contract (SPEC.md, SCHEMA.md, BENCH.md)
tools/ vectorgen — deterministic workload generator
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
ctest --test-dir build --output-on-failure # 43 golden vectors
# benchmark (see spec/BENCH.md)
mkdir -p bench/corpora
cargo run --release --manifest-path tools/vectorgen/Cargo.toml -- \
--workload w2 --n 200000 --setup-n 100000 --out bench/corpora/w2
./build/matcherbench bench/corpora/w2MIT OR Apache-2.0