A C++23 matching engine implementation featuring a real-time graphical visualiser built with Raylib.
- Modern C++: Uses C++23
std::generator(coroutines),std::ranges, andstd::format. - Order Types: Supports GoodTillCancel, FillAndKill, FillOrKill, and Market orders.
- Matching Logic: Price-Time priority (FIFO) using
std::mapandstd::list. - Visualiser: Real-time histograms for market depth (Bids/Asks) and trade frequency.
- Analytics: Live median and quartile trade price calculation.
- OrderBook: Manages two sorted maps (Bids descending, Asks ascending).
-
Order Tracking: Uses an
unordered_map<Uuid, list::iterator>for$O(1)$ cancellations. -
Coroutines: Uses
std::generatorto stream orders and trades without extra allocations. - Quantity/Price: Dedicated classes using 64-bit integers to prevent floating-point errors.
The GUI (built with Raylib) displays:
- Asks (Top): Volume distribution of sell orders.
- Bids (Bottom): Volume distribution of buy orders.
- Trades (Center): Histogram of execution prices.
- Stats: Live quartile data overlay based on historical trade volume.
Requirements:
- C++23 compatible compiler (GCC 13+, Clang 17+, MSVC 19.38+).
- Raylib 5.0+ installed on your system.
Commands:
mkdir build && cd build
cmake ..
cmake --build .