Order Matching Engine

Build a high-performance matching engine that processes 1,000,000 orders, executes trades, and computes P&L. Beat the clock.

1M
Orders
1,000
Traders
< 500ms
Gold Target
4
Languages

The Problem

Given 1,000,000 order events (limit orders, market orders, cancels) for a single instrument, implement a price-time priority order book that matches trades and computes per-trader P&L on a FIFO basis.

Your engine must handle self-trade prevention, partial fills, and Immediate-or-Kill semantics for market orders. Output must match the reference solution exactly.

Performance Tiers

GOLD< 500 msExceptional
SILVER< 2 sStrong
BRONZE< 10 sAcceptable
FAIL> 10 sBelow bar

Python solutions use relaxed tiers (Gold < 5s).

Supported Languages

C++ (g++ -O2 -std=c++20) Rust (rustc -O --edition 2021) Java (javac + java) Python 3 (python3)

Full Problem Spec

The complete specification includes input/output schemas, matching rules, P&L calculation details, FAQ, and hints.

View Full Spec

Starter Templates

Download a skeleton for your preferred language. Each includes CSV parsing, struct definitions, and TODO markers for the core logic.

skeleton.cpp skeleton.rs Skeleton.java skeleton.py

Evaluation Criteria

Correctness (50%)

Trade output must exactly match the reference (order IDs, prices, quantities). P&L values within ±$0.01. Edge cases: self-trade prevention, cancel of partially-filled orders, market orders with no liquidity.

Performance (30%)

Wall-clock time on the 1M order dataset. Memory usage (peak RSS). We may test scaling behavior with 10M rows.

Code Quality (20%)

Data structure choices and justification. Memory layout and cache efficiency. Error handling and robustness. Clarity and readability. Submit a DESIGN.md explaining your approach.