A deterministic, high-efficiency matching engine implemented in C++20. This project simulates a financial exchange by matching buy and sell limit orders using Price-Time Priority (FIFO).
The engine utilizes a Nested Map-of-Lists architecture to achieve high-performance algorithmic complexity:
-
Price Discovery:
std::map(Red-Black Tree) ensures$O(\log P)$ lookup for the best bid/ask. -
Priority Management:
std::list(Doubly Linked List) maintains$O(1)$ time priority at each price level. -
Order Tracking:
std::unordered_mapprovides$O(1)$ direct access to orders for instant cancellation.
| Operation | Complexity | Implementation Details |
|---|---|---|
| New Order | Logarithmic price search + |
|
| Cancellation | Hash-map iterator lookup | |
| Modification | Direct node access via iterator |
Ensure you have a C++20 compatible compiler (Clang/GCC).
# Compile
g++ -std=c++20 -Iinclude src/*.cpp -o engine
# Run
./engine