Ticker Plant
Hard ● Live C++ Rust Java PythonThe Problem
Normalize and aggregate 2,000,000 trade messages from 4 different stock exchanges into consolidated OHLCV (Open, High, Low, Close, Volume) bars. Each exchange has different timestamp formats, decimal precision, and message ordering.
The ticker plant is the heart of market data infrastructure: it consumes raw exchange data and produces standardized, time-bucketed quotes for the rest of the trading system.
Evaluation Criteria
Correctness (70%)
All trades aggregated correctly. OHLCV values must be exact within 0.01 per value. Time bucketing and exchange deduplication must be 100% accurate.
Performance (30%)
Wall-clock time on 2M trades from 4 exchanges.
Exchange Message Format
NYSE Format
ISO 8601 timestamp, symbol, price, volume, buyer_id, seller_id
2026-01-01T09:30:00.000Z,AAPL,150.25,1000,BUYER_A,SELLER_B
NASDAQ Format
Unix milliseconds, symbol, price (2 decimals), quantity, exchange_id
1704110400000,MSFT,300.50,500,NASDAQ
CBOE Format
Unix microseconds, symbol, price (4 decimals), quantity
1704110400000000,GOOG,140.2500,750
IEX Format
Custom: HHMMSS.mmm, symbol, price, size
093000.000,TSLA,250.10,2000
Aggregation Rules
Time Buckets
Aggregate trades into 1-second OHLCV bars. Bucket = floor(timestamp / 1000) * 1000.
OHLCV Computation
- Open: first trade price in bucket
- High: max trade price in bucket
- Low: min trade price in bucket
- Close: last trade price in bucket
- Volume: sum of all trade quantities in bucket
Deduplication
Messages with identical (timestamp, symbol, price, volume) are duplicates and should be counted only once.
Input Format
- First line
N= total number of messages across all exchanges.- Each message
- pipe-separated, first field is the exchange tag, remaining fields vary by exchange:
NYSE|<ns_timestamp>|symbol|price|volume|side- NYSE timestamps are nanoseconds since epoch.NASDAQ|<ns_timestamp>|symbol|price|volume|side- NASDAQ also nanosecond precision.IEX|<float_seconds>|symbol|price|volume|side- IEX timestamps are floating-point seconds since epoch.BATS|<ms_timestamp>|symbol|price|volume|side|TXid- BATS timestamps are milliseconds since epoch and include a trailing transaction id.
Output Format & Sample
Sample input (first 8 lines, full file linked below):
30 NYSE|1609459302034126396|AMZN|159.98|180|B NYSE|1609459583768820204|AAPL|149.63|280|B IEX|1609460918.163032|ADBE|500.12|10|B NYSE|1609462327385451171|NVDA|850.66|440|B IEX|1609461672.307419|NFLX|399.99|590|B BATS|1609459302081|AMZN|159.98|180|B|TX349957310 BATS|1609460756686|AMZN|159.86|470|B|TX386665249 ... (more)
Expected output for that sample (first 8 lines):
16 28 1609459213 SHOP 519.260000 519.260000 519.260000 519.260000 930 519.260000 1 1609459286 GOOG 139.090000 139.090000 139.090000 139.090000 290 139.090000 1 1609459302 AMZN 159.980000 159.980000 159.980000 159.980000 360 159.980000 2 1609459460 MU 85.230000 85.230000 85.230000 85.230000 500 85.230000 1 1609459476 AMD 139.620000 139.620000 139.620000 139.620000 50 139.620000 1 1609459582 AAPL 150.620000 150.620000 150.620000 150.620000 970 150.620000 1 1609459583 AAPL 149.630000 149.630000 149.630000 149.630000 280 149.630000 1 ... (more)
↓ download full sample input | ↓ download expected output
Test your solution locally:
./your_solution < input.txt | diff - output.txt
Common Pitfalls
- Normalize all timestamps to seconds. NYSE/NASDAQ /1e9, IEX as-is, BATS /1e3. Then bucket by floor(seconds).
- Output 1-second OHLCV bars per symbol, sorted by symbol then by timestamp.
- Compute VWAP per bar = sum(price*volume) / sum(volume). Track running numerator and denominator; don't store all trades per bar.
- BATS includes an extra field. Don't crash on the 7th column; ignore it.
- 2,000,000 messages across 20 symbols and 4 exchanges. Pre-allocate per-symbol bar arrays if you can predict the time range.
Performance Tier Thresholds (applied by the grader)
| Language | Gold | Silver | Bronze | Tier 4 |
|---|---|---|---|---|
| C++ | <500ms | <2000ms | <8000ms | else PASS |
| Rust | <500ms | <2000ms | <8000ms | else PASS |
| Java | <1000ms | <4000ms | <15000ms | else PASS |
| Python | <4000ms | <12000ms | <50000ms | else PASS |
Submission Rules
- Single-file solutions only. All code must be in one file.
- Your program must read from stdin and write to stdout.
- Java class must be named Solution.
- No network access, no filesystem access beyond stdin/stdout.
- Time limit: 120 seconds. Memory limit: 2 GB.