Case Study — Deterministic C++ order book & algorithmic backtesting suite

QuantDesk

A high-performance algorithmic trading platform with a deterministic C++ matching engine supporting LIMIT, MARKET, IOC, and FOK orders with price-time priority, Avellaneda-Stoikov market making, and an interactive React analytics dashboard for strategy replay.

quantdesk-mu.vercel.app
Screenshot of QuantDesk
C++20CMakeGoogleTestPythonReactQuantitative TradingFastAPI
01

Overview

QuantDesk is an institutional-grade quantitative trading backtesting and simulation suite. It pairs a deterministic C++20 limit order book matching engine with a Python quantitative research environment and an interactive React web dashboard for strategy replay, depth-of-book analysis, and performance analytics.

02

The Problem

Standard backtesting libraries written purely in Python suffer from significant execution latency, unrealistic fill assumptions, and execution drift when simulating high-frequency or inventory-sensitive strategies like market making and pairs trading.

03

My Contribution

Architected a native C++20 matching engine implementing price-time priority queues with microsecond event dispatching. Implemented an inventory-aware Avellaneda-Stoikov market maker that dynamically skews bid-ask spreads, and built a full-stack React frontend for historical order replay.

04

Architecture

Deterministic C++ Matching Engine

Implemented price-time priority queues for bids and asks using memory-efficient contiguous price buckets. Supports LIMIT, MARKET, IOC (Immediate-or-Cancel), and FOK (Fill-or-Kill) orders with immediate partial fill settlement.

Avellaneda-Stoikov Market Making

Implemented the seminal Avellaneda-Stoikov optimal quoting model. As inventory accumulates in either direction, reservation prices skew quotes away from accumulating adverse inventory while maintaining target spread capture.

Statistical Arbitrage & Cointegration

Engineered a pairs trading pipeline in Python utilizing Johansen cointegration tests, rolling z-score spread calculations, and volatility-scaled half-life rebalancing thresholds.

Interactive Strategy Replay Dashboard

Built a React dashboard displaying real-time depth of book heatmaps, cumulative PnL trajectories, drawdown charts, and per-fill execution slippage logs.

05

Engineering Decisions & Tradeoffs

C++20 for core execution engine instead of Python

Rationale: Python backtesting introduces substantial runtime overhead and cannot accurately model deterministic microsecond execution without language runtime artifacts.

Tradeoff: Requires cross-language bindings and CMake build pipelines compared to an all-Python stack.

Avellaneda-Stoikov quoting over naive fixed spreads

Rationale: Fixed-spread market makers suffer heavy adverse selection during directional price shocks. Dynamic reservation pricing protects capital by penalizing inventory build-up.

Tradeoff: Requires accurate continuous estimation of volatility (gamma) and arrival intensity (kappa).

06

Challenges & Solutions

Challenge

Ensuring 100% deterministic execution across test runs

Solution

Enforced explicit monotonic timestamp indexing, isolated PRNG seeding, and automated GoogleTest suites verifying exact order book state parity across runs.

Challenge

Handling multi-level liquidity sweeps without allocation bottlenecks

Solution

Designed a recursive price-level decrement loop that updates book volume in-place before emitting execution reports.

07

Evidence & Results

  • ›Sub-microsecond order matching on synthetic and historical book feeds
  • ›Deterministic order execution validated by comprehensive GoogleTest coverage
  • ›Live interactive web dashboard deployed at https://quantdesk-mu.vercel.app/
  • ›Supports full order lifecycle (LIMIT, MARKET, IOC, FOK) with partial fill logic
All Projects View Repository Live Demo