KatInterview

Build an Extensible Event-Driven Trading Strategy Framework

System DesignModel answer
MediumModel answerSystem Designevent-driventradingframework-design

Last updated

Design a maintainable framework that routes market events to trading strategies, manages order lifecycle, and runs identically in backtests and live trading.

The Problem

Your team is building an internal platform where multiple quantitative strategies run side by side. You have been asked to design and sketch the core framework they will all share — one that the team can keep extending long after the initial version ships.

The framework has two jobs: deliver events (new market data, fills, timer ticks, etc.) to each strategy in a well-defined order, and carry out whatever orders a strategy decides to send. Individual developers should be able to write a new strategy without touching framework internals.

Describe the architecture you would build, the core interfaces a strategy author would implement, and the path an event takes from arrival through to an order being sent.

What is expected

  • A clear architecture diagram or description of the major components and how they connect
  • The core interfaces: what a strategy must implement, what the framework provides to it
  • How the event loop works: ordering guarantees, time handling, and dispatch
  • How the same strategy code runs in a historical backtest, a paper-trading simulation, and live
  • How the framework handles order lifecycle, position tracking, and pre-trade risk checks
  • What makes the framework safe to extend: strategy isolation, logging, tests, and documentation

Constraints and clarifications

  • Asset class, language, data sources, venues, and latency targets are not specified — state your assumptions or ask
  • This is a deliverable other people will maintain; interfaces, tests, and documentation are part of the answer
  • Worth addressing: what happens when one strategy crashes or misbehaves, and how a new venue or data source is added without changing existing code

Good clarifying questions to raise

  • Should the same strategy instance run unmodified across backtest, paper, and live modes?
  • Which event types must be supported at launch: top-of-book quotes, trade prints, OHLCV bars, order acknowledgements, partial and full fills, rejections, and/or timer events?
  • Do strategies share market data subscriptions, a common position ledger, or per-strategy risk limits?
  • Is there an existing order-routing or market-data infrastructure to integrate with, or is everything greenfield?
  • Is microsecond latency a hard requirement, or is developer ergonomics the priority?

Hints

Hint 1

Start with the event model before anything else. Define a sealed Event type hierarchy so every component in the system speaks the same language. A poorly typed event model causes subtle bugs that are expensive to fix once strategies are written on top of it.

Hint 2

The key to backtest/live parity is a Clock abstraction. If every component that needs to know the current time calls `clock.now()` rather than the system clock, you can replay history at any speed and the strategy code never changes.

Hint 3

Put a risk and order manager between the strategy and the venue — strategies call `submit_order()` on the framework, never on the venue directly. This is where you enforce position limits, rate limits, and size checks without asking strategy authors to remember to do it themselves.