A framework for any trading design question
- Clarify scope: exchange side (matching engine, order book) or participant side (market data handler, strategy, order management, risk)? Which latency tier: microseconds, milliseconds, or minute bars?
- List requirements: functional needs, latency and throughput targets, correctness guarantees (never lose an order, never double-process a fill), and failure behavior.
- Sketch components and data flow, then deep-dive on the hardest part.
- Cover failure modes: crashes, gaps, duplicates, slow consumers, bad data, operator error.
- Cover observability and safety: monitoring, replay, limits and kill switches.
Market data and research platforms
Q1. Design a market data ingestion and storage system for ETF, stock and futures prices used by both research and live pricing.
Q1. Design a market data ingestion and storage system for ETF, stock and futures prices used by both research and live pricing.
- Ingestion layer: One adapter per source, normalizing each vendor format into one internal schema (symbol, UTC timestamp, quote, trade, source, receive time). Keep raw data immutably.
- Real-time path: A low-latency message queue or stream feeding the pricing and risk services. Handle out-of-order data, duplicates, disconnects and backpressure.
- Historical storage: Time-series or columnar storage partitioned by date and symbol. The real-time path writes continuously, and a batch job later recomputes and reconciles.
- Quality and monitoring: Automated detection and alerting for gaps, stale data, outliers and latency.
Q2. Design a market data distribution system for several strategies on the same machine or network.
Q2. Design a market data distribution system for several strategies on the same machine or network.
- Redundant feeds: Consume two copies of the same feed and arbitrate by sequence number, so a dropped packet on one line is covered by the other.
- Gap recovery: Track sequence numbers per channel. On a gap, request a retransmission or a snapshot, and mark the affected book as uncertain until it is repaired.
- Fan-out: Decide between latency and flexibility. Shared memory or multicast gives the lowest latency, while a message bus is easier to operate. Slow consumers must not block fast ones, so use bounded queues and a drop or disconnect policy.
- Normalization: One internal format with explicit time zones, price scaling and instrument identifiers.
- Replay: Record the input stream so any session can be replayed for debugging and testing.
Q3. Design a backtesting framework. Event-driven or vectorized?
Q3. Design a backtesting framework. Event-driven or vectorized?
- Vectorized: Fast and simple to implement, suitable for signal research and daily-frequency strategies. The weakness is that path-dependent logic (stops, position limits, volume constraints) is hard to model.
- Event-driven: Consumes events in time order (quotes, trades, order acknowledgements) and can share logic with the live system. It is more realistic but slower and more complex.
- One time axis, and signals can only use data known at that time.
- Pluggable cost models: spread, fees, borrow, slippage.
- Reproducibility: Record code version, data version, parameters and random seed, so the same inputs give the same result.
- Accurate replay of recorded market data, walk-forward validation, and reports with P&L attribution, not just a Sharpe ratio.
Q4. How do you bridge research code and production code?
Q4. How do you bridge research code and production code?
- Shared core: Put signal and pricing logic in one library used by both research notebooks and the live system.
- Same data interface: The strategy reads data through the same abstraction in backtest and live, with a replay source in one and a live feed in the other.
- Parity tests: Run the live code path on recorded data and compare its decisions with the backtest output.
- Shadow mode: Run new logic in production with real data but no orders, and compare it with expectations before enabling trading.
- Configuration, not copies: Parameters live in versioned configuration, not edited copies of the code.
Trading components
Q5. Design an in-memory order book and matching engine for one venue.
Q5. Design an in-memory order book and matching engine for one venue.
- Each side of the book is a sorted structure of price levels, so the best price is fast to read.
- Each price level holds a first-in, first-out queue of orders, which implements time priority.
- A hash map from order ID to the order’s position allows cancellation without scanning the book.
- Cache the best bid and best ask so top-of-book reads are constant time.
Q6. Design an order management system (OMS).
Q6. Design an order management system (OMS).
- Order state machine: New, acknowledged, partially filled, filled, canceled, rejected, with explicit legal transitions. Illegal transitions are logged and alerted, not ignored.
- Idempotency: Give every order a unique client order ID so that retries after a timeout cannot create duplicates.
- Concurrency: Several strategies may submit at once. Serialize state changes per order, and enforce pre-trade limits atomically with submission.
- Reconciliation: Compare internal orders and positions with the broker or exchange regularly and at startup, and treat the external record as the authority.
- Persistence: Write every state change to a durable log so that a restart can rebuild the open order set.
Q7. Design a live pricing and hedging service for an ETF market maker. How do you make it safe?
Q7. Design a live pricing and hedging service for an ETF market maker. How do you make it safe?
- Stale data protection: If any input has not updated within a time limit, quotes automatically widen or are pulled.
- Sanity checks: Reject quotes that deviate too far from fair value or show abnormal price jumps.
- Risk limits: Hard limits on position, notional, order rate and order size.
- Isolation: Keep pricing, execution and risk checks separate so one failing module does not take down the rest.
- Observability: Monitor latency, rejection rate and position breaks, with alerts.
Q8. Design the kill switch for an automated trading system. How do you make sure the kill switch itself cannot fail?
Q8. Design the kill switch for an automated trading system. How do you make sure the kill switch itself cannot fail?
- Keep it independent from the code it protects, so a bug in a strategy cannot disable it.
- Fail closed: if the kill switch loses contact with the system, the default is to stop.
- Test it regularly in a controlled way, because an untested kill switch is not a control.
- Give operators a simple, fast manual path that does not depend on the main application.
Q9. Design a pre-trade risk check that no outbound order can bypass.
Q9. Design a pre-trade risk check that no outbound order can bypass.
- Check and reserve atomically: an approved order reserves its exposure against the limit before it is sent, and the reservation is released on cancel, reject or fill. Otherwise two orders sent at the same time can both pass and together breach the limit.
- Idempotency and reconciliation: duplicated or reordered acknowledgements and fills must not double-count usage, so key every update by order ID and fill ID and reconcile against the venue.
- Fail closed: if the risk state is stale, the configuration cannot be loaded, or the gateway state is ambiguous, reject new orders rather than let them through.
- Latency: the check is on the critical path, so keep the limit state in memory, avoid locks shared with slow components and measure its latency percentiles.
- Operations: limit changes are audited and approved, and there is an emergency path to tighten limits during an incident.
Q10. Design a real-time position and P&L service for a market-making desk.
Q10. Design a real-time position and P&L service for a market-making desk.
- Event sourcing: positions are the sum of start-of-day positions and fills, rebuilt from the fill log after any restart.
- Price choice: define which price marks each instrument (mid, last trade, fair value model) and flag marks that are stale.
- P&L split: separate realized from unrealized P&L, and trading P&L from start-of-day position P&L, so traders can see what today’s activity did.
- Consistency: each fill updates position and P&L in one step, and late or corrected fills are applied without double-counting.
- Reconciliation: compare intraday positions with broker and clearing reports, and end-of-day P&L with the official books, and alert on breaks.
- Fan-out: many readers (traders, risk, dashboards) should read snapshots or a stream, not query the write path.
Related pages
Sources
- Algorithmic Trading System Architecture (techinterview.org)
- System Design: Electronic Trading Platform (techinterview.org)
- Design an in-memory order matching engine (PracHub)
- Quant Developer Interview Questions and Prep (Exponent)
- Design a pre-trade risk check for an electronic order path (PracHub)
- Design a low-latency trading system (PracHub)
- Quant developer interview questions: 25 real examples (Quantt)

