All ProjectsA.S.
02  —  Case StudyFinTech & Real-Time Systems2024

MarketEx

"High-performance trading exchange and real-time market order book simulation."

MarketEx preview showcase
I  —  Overview

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 simulation
II  —  Problem & Goals

The Challenge

Standard financial educational simulators often suffer from delayed polling, unrealistic order execution, and unresponsive interfaces during high trading volume events.

Key Objectives

01Implement an in-memory price-time priority (FIFO) matching engine capable of processing microsecond order fills.
02Stream live tick data and depth charts to connected clients via full-duplex WebSockets.
03Manage stateful market data using Redis pub/sub for decoupled broadcasting.
04Deliver an institutional-grade dark trading terminal interface with responsive charts.
III  —  Key Features
01

Limit Order Book Engine

Deterministic price-time matching supporting Market, Limit, and Stop-Loss order executions.

02

Real-Time WebSocket Feed

Sub-millisecond market depth updates and trade execution notifications pushed directly to browsers.

03

Interactive Candlestick Charts

Dynamic charting with multiple timeframes (1m, 5m, 1h, 1D) and volume indicators.

04

Portfolio & PnL Analytics

Real-time margin calculation, unrealized and realized PnL tracking, and transaction ledgers.

IV  —  Tech Stack

Frontend

  • React
  • TypeScript
  • Tailwind CSS
  • Canvas Charts

Backend

  • Node.js
  • TypeScript
  • WebSocket (ws)

Database & Cache

  • Redis (Pub/Sub & Caching)
  • PostgreSQL

Tools & Utilities

  • Docker
  • Git
  • Postman
V  —  Architecture

System Architecture & Data Flow

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.

VI  —  Engineering

Development Approach

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.

Challenges Encountered & Solutions

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.

VII  —  Gallery
MarketEx live trading interface
Live market trading terminal and depth chart
MarketEx order book analytics
Order book matching engine analytics and tick stream
MarketEx portfolio analytics
Portfolio equity curve and performance breakdown

Click any image to view in high-resolution lightbox.

VIII  —  Learnings

Project Outcomes

Demonstrated sustained processing of over 10,000 simulated orders per second with sub-5ms client-side rendering latency.

Future Roadmap

  • →Backtesting engine for algorithmic trading strategies written in Python.
  • →Decentralized wallet connectivity (Web3 / MetaMask).
  • →Fix/QuickFIX protocol integration for institutional connectivity.