How abhinavsaurabh/low-latency-cpp-matching-engine works
This is a compact, single-symbol exchange-style matching engine. An order-entry client submits an order; the engine sequences it, checks pre-trade limits, and delegates book operations. The book applies price-time priority, updates resting liquidity, and produces command events; the engine updates positions from executions and returns results. Clients can also cancel or modify orders and inspect best bid/ask snapshots. The graph preserves the documented limit/market, IOC, event, and risk capabilities. Source excerpts establish the main calls; unsampled interface declarations and demo behavior are represented only where README or indexed references support them.
Main entry points: matching_engine.cpp Matching engine · order_book.cpp Order book · risk.cpp Pre-trade risk · execution.hpp Events and snapshots
Components 10
Order entry
- Matching engine
src/matching_engine.cpp
Matching core
- Pre-trade risk
src/risk.cpp - Order book
src/order_book.cpp - Price-time matching
src/order_book.cpp
Book and risk state
- Book state
include/hft/order_book.hpp - Trader positions
src/risk.cpp
Domain model
- Order model
include/hft/order.hpp - Events and snapshots
include/hft/execution.hpp - Shared trading types
include/hft/types.hpp
Other components
- Order-entry client
Connections 15
- Order-entry client → Matching engine: submits commands
README.md - Matching engine → Pre-trade risk: validates orders
src/matching_engine.cpp - Matching engine → Order book: delegates commands
src/matching_engine.cpp - Matching engine → Pre-trade risk: records fills
src/matching_engine.cpp - Order book → Price-time matching: matches flow
src/order_book.cpp - Price-time matching → Book state: updates liquidity
src/order_book.cpp - Order book → Book state: reads and maintains
include/hft/order_book.hpp - Pre-trade risk → Trader positions: reads and updates
src/risk.cpp - Matching engine → Order model: checks and sequences
src/matching_engine.cpp - Order book → Order model: adds and modifies
src/order_book.cpp - Order book → Events and snapshots: creates results
src/order_book.cpp - Matching engine → Events and snapshots: returns command results
src/matching_engine.cpp - Events and snapshots → Shared trading types: uses shared types
include/hft/execution.hpp - Order book → Events and snapshots: uses event model
- Pre-trade risk → Order model: validates order fields