This trading engine implements a limit order book system, which is a core component of electronic trading platforms. It efficiently manages buy and sell orders, maintains price-time priority, and executes trades when orders match.
- Double-sided order book (buy side and ask side)
- FIFO (First In, First Out) matching algorithm
- Fast order insertion, deletion, and modification
- Trade execution and reporting
- Order: Represents individual buy/sell orders with price, quantity, and type.
- Limit: Price level that contains a linked list of orders at the same price.
- OrderBook: Main component that manages the order book structure and matching logic.
- Trade: Represents matched trades with price, quantity, and timestamp.
- Market: Simulates market data generation with realistic price movements.
- Ticker: Contains market data like bid/ask prices and volumes.
- Limit: Manages orders at a specific price level.
- Order: Individual order representation.
- OrderBook: Manages the full order book structure with
SortedDictfor optimal performance.
- C++: Custom linked lists for efficient order management.
- Python:
SortedDictfor O(log n) price level access. - Both: O(1) order removal and O(1) matching for most cases.
- Pro-rata matching algorithm implementation.
- Market data feed integration.
- Persistence layer for order storage.
- Performance benchmarking suite.
- REST API for order submission.