A small, beginner-friendly simulation of how real electronic trading systems work. This project includes:
- A market data feed (simulated prices)
- A limit order book
- A matching engine (matches buy & sell orders)
- UDP networking to broadcast trades
- Latency measurement (microseconds)
It’s a simplified version of how exchanges like NASDAQ/NYSE actually behave.
FeedHandler → generates fake market prices
TradingSystem → creates random buy/sell orders
MatchingEngine → matches orders using price–time priority
Trades → logged + sent out via UDP
Simulates live market data for AAPL, GOOGL, MSFT, AMZN.
Stores and sorts bids/asks with price-time priority.
Matches orders when best bid ≥ best ask and generates trades.
Broadcasts trades using UDP in CSV format.
Coordinates everything, generates random orders, measures latency, prints summary.
mkdir build && cd build
cmake ..
make
./trading_system
[FEED] AAPL @ 152.34 x 3421
[ORDER] Buy AAPL 320 @ 151.42 (Latency: 10.54 μs)
[TRADE] AAPL 100 @ 152.10 (E2E: 24.31 μs)
Latency stats + order book summary printed at end.