Katkat

Design A Real-Time VWAP Analytics Provider

BloombergSoftware Engineer · Technical Screen

Last updated

Tests the ability to design an ultra-low-latency, stateful streaming pipeline that ingests heterogeneous market data feeds, maintains running volume-weighted aggregates, handles trade adjustments, and serves high-throughput subscriber fanout.

Product Scenario

Design a real-time market data analytics service that ingests tick-by-tick equity trades from multiple global exchanges, normalizes them into a canonical format, and computes real-time Volume-Weighted Average Price (VWAP) for every active instrument.

VWAP is defined as: VWAP = sum(Price_i * Volume_i) / sum(Volume_i)

The system must compute both cumulative trading session VWAP (from market open to current time) and rolling-window VWAP (e.g., rolling 5-minute, 1-hour windows), delivering real-time streaming updates to trading desks and offering historical point-in-time lookups.

Requirements

Functional Requirements

  • Feed Ingestion & Normalization: Ingest raw trades across 50+ exchanges using different protocols (e.g., NASDAQ ITCH, FIX, binary multicast) and normalize to an internal canonical tick model.
  • Aggregation: Continuously compute cumulative session VWAP and rolling-window VWAP per ticker.
  • Trade Corrections: Handle trade cancellations, busts, and out-of-order ticks by updating running values appropriately.
  • Egress: Push VWAP updates to downstream subscribers with minimal delay and provide an enterprise query API for point-in-time and end-of-day VWAP figures.

Non-Functional Requirements

  • Low Latency: End-to-end processing latency (tick arrival at feed handler to publication) must be under 5 milliseconds at p99.
  • Fault Tolerance & Recovery: If an aggregation node crashes, recovery to the correct state must take less than 5 seconds without reprocessing the full day's tick log.
  • High Availability: 99.99% availability during market hours across multi-region exchange clusters.

Scale Assumptions

  • Tickers: 20,000 active symbols.
  • Throughput: Average 100,000 ticks/second; peak 1,000,000 ticks/second (market open/close and volatility spikes).
  • Downstream Consumers: 50,000 concurrent internal and external subscriber sessions.
  • Data Retention: Raw normalized ticks retained for 7 years; sub-second VWAP snapshots retained for 90 days.

What Your Solution Should Cover

  • Architecture Diagram: Feed handlers, message transport, stateful stream processing, storage tier, and egress fanout.
  • State Management: How running cumulative volume and dollar value (cumulative_notional = sum(P * V)) are maintained and snapshotted.
  • Trade Busts / Corrections: Strategy for recalculating VWAP when exchanges report canceled trades.
  • Pub/Sub & API Design: Interface and protocols for downstream streaming updates and historical queries.

Hints

Hint 1

Partition streaming state strictly by ticker symbol using consistent hashing to avoid distributed locks when updating running cumulative sums.

Hint 2

Rather than storing every raw tick in memory to compute session VWAP, maintain running accumulators for cumulative notional value and cumulative volume.

Hint 3

For rapid failover, combine periodic memory checkpoints of accumulators with an append-only write-ahead log or high-performance event stream to replay only recent ticks.

Follow-up questions

  • How does your architecture handle trade cancellations (busts) that arrive 10 minutes after the original trade execution?
  • If a feed handler experiences a burst that exceeds downstream processing capacity, how do you handle backpressure without dropping tick accuracy?
  • How would you extend the design to support arbitrary user-defined time-slices (e.g., VWAP between 10:15 AM and 11:30 AM) efficiently?