Execution Simulator

Hard ● Live C++ Rust Java Python

The Problem

Implement TWAP (Time-Weighted Average Price) and VWAP (Volume-Weighted Average Price) execution algorithms. Given a parent order of N shares and 1 million OHLCV bars, optimally split execution to minimize implementation shortfall.

Compute metrics: execution prices, shortfall, total costs, bars executed. Test interview skills for quant trading and HFT roles.

Evaluation Criteria

Correctness (70%)

Both strategies must execute correct total quantity. Shortfall and prices accurate to 6 decimal places.

Performance (30%)

Wall-clock time on 1M bars with 100K share parent order.

Input Format

First line
SIDE PARENT_QTY NUM_BARS where SIDE is BUY or SELL, PARENT_QTY is the total quantity to execute, NUM_BARS is the number of OHLCV bars that follow.
Each bar
timestamp,open,high,low,close,volume (comma-separated).
Two algorithms to run
TWAP (equal time slices across all bars) and VWAP (weighted by each bar's volume share).

Output Format & Sample

Sample input (first 8 lines, full file linked below):

BUY 100000 30
1700000000,99.99,100.07,99.90,99.95,13339
1700000001,99.93,100.68,99.19,100.52,12521
1700000002,100.50,100.56,100.44,100.47,15032
1700000003,100.53,100.59,100.48,100.55,15269
1700000004,100.57,101.23,99.92,100.98,12038
1700000005,101.03,101.76,100.31,100.80,12932
1700000006,100.89,101.01,100.77,100.79,12580
... (more)

Expected output for that sample (first 8 lines):

99.990000
100.728576
100.728433
0.007386
0.007385
10072857.580000
10072843.317500
30
... (more)

↓ download full sample input  |  ↓ download expected output

Test your solution locally: ./your_solution < input.txt | diff - output.txt

Common Pitfalls

Performance Tier Thresholds (applied by the grader)

LanguageGoldSilverBronzeTier 4
C++<500ms<2000ms<10000mselse PASS
Rust<500ms<2000ms<10000mselse PASS
Java<1000ms<4000ms<15000mselse PASS
Python<5000ms<15000ms<60000mselse PASS

Submission Rules

Challenge Stats

Market bars: 1,000,000
Parent order: 100,000 shares
Strategies: 2 (TWAP, VWAP)
Output metrics: 9

Starter Templates

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

Submit Your Solution

You can submit multiple times. Best result per language counts.

Resources

Leaderboard →