Foundational System Design Concepts with Applications to Quantitative Finance

The goal

I'm trying to learn some system design fundamentals, with an emphasis on quantitative finance. To do this, I've aggregated some common design cases for building quant trading infrastructure.
For each system design problem, I will include the following:

  • (a) A brief description about what is being designed and why it is necessary.
  • (b) The functional requirements.
  • (c) The solution, which includes the high level components, data structures used, and other important details.
  • (d) Follow-up questions presenting potential further challenges, along with their solutions.



1. Order Matching Engine

(a) Description

An Order Matching Engine is the core component of any trading system that automatically pairs buy and sell orders for financial instruments. When traders submit orders to buy or sell at specific prices, the engine finds compatible orders and executes trades. The engine should maintain an orderbook full of submitted orders on both the buy and sell side.

(b) Functional Requirements:

  • Accept buy and sell orders with price, quantity, and timestamps
  • Match compatible orders using price-time priority (best price first, then FIFO)
  • Handle partial fills when order quantities don't exactly match
  • Process 10,000+ orders per second with sub-millisecond latency


Let's start by making some assumptions about our functional requirements, from which we will start weighing different design decisions for a solution.

2. Price Feed Processor

Design a system that receives stock price updates from multiple data sources and provides the latest price for any stock symbol.

3. Rate Limiter

Design a rate limiting service that prevents trading applications from making too many API calls and overwhelming downstream systems.

Comments

No comments yet.