"High-performance trading exchange and real-time market order book simulation."
MarketEx is a simulated financial trading exchange built to model limit order books, bid-ask matching algorithms, and low-latency price dissemination. It supports simulated equity and cryptocurrency pairs with streaming candlestick charts and real-time portfolio tracking.
Executive Summary
Trading platform & exchange simulationStandard financial educational simulators often suffer from delayed polling, unrealistic order execution, and unresponsive interfaces during high trading volume events.
Deterministic price-time matching supporting Market, Limit, and Stop-Loss order executions.
Sub-millisecond market depth updates and trade execution notifications pushed directly to browsers.
Dynamic charting with multiple timeframes (1m, 5m, 1h, 1D) and volume indicators.
Real-time margin calculation, unrealized and realized PnL tracking, and transaction ledgers.
Engineered around an event-driven architecture. Incoming order requests are validated by an API gateway, passed to a single-threaded in-memory order book matching engine to avoid lock contention, and committed to Redis. Redis Pub/Sub fans out execution reports to WebSocket worker nodes, which push low-latency market depth deltas to active browser sessions.
Modeled the order book using doubly linked lists index-mapped by binary search trees for O(1) order cancellation and O(1) best bid/ask lookups. Profiled WebSocket message serialization to minimize memory allocations under rapid bursts.
Maintaining clock synchronization and preventing race conditions during concurrent order placements. Addressed this by enforcing single-threaded deterministic event queuing for matching transactions combined with optimistic locking on user account balances.
Click any image to view in high-resolution lightbox.
Demonstrated sustained processing of over 10,000 simulated orders per second with sub-5ms client-side rendering latency.