stock-exchange

Design a stock exchange matching engine with deterministic state-machine replication.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/hung-phan/system-skills --skill stock-exchange
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stock-exchange
Source: https://github.com/hung-phan/system-skills/tree/main/skills/system-review/references/interview-templates/stock-exchange
Command: npx skills add https://github.com/hung-phan/system-skills --skill stock-exchange

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sortedcontainers, collections, dataclasses, itertools, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill guides you through designing a robust and efficient stock exchange matching engine, addressing challenges related to order matching, determinism under replication, and failure.

Core Features & Use Cases

  • Matching Engine Design: Provides a comprehensive framework for designing a matching engine, covering price-time priority, deterministic matching, and state-machine replication.
  • High Availability: Implements replication strategies to ensure fault tolerance and state consistency across multiple nodes.
  • Market Data Handling: Offers insights into handling market data dissemination, including UDP multicast for efficient distribution.
  • Circuit Breakers: Implements circuit breakers at order, symbol, and market levels to mitigate system instability.
  • Use Case: Ideal for designing matching engines for exchanges, particularly for equities and crypto exchanges, dealing with high throughput and strict latency requirements.

Quick Start

Analyze the architecture diagram for your new payment service using /system-review review architecture-diagram.png

Frequently Asked Questions about stock-exchange

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a matching engine for high-frequency trading?

A matching engine for high-frequency trading requires deterministic state-machine replication and single-threaded logic to handle high throughput with strict latency. This Skill provides a framework covering price-time priority and fault tolerance across multiple nodes.

What is state machine replication in a stock exchange matching engine?

State machine replication in a matching engine ensures determinism under replication, guaranteeing fault tolerance and state consistency across multiple nodes. It enables the system to process identical inputs sequentially and maintain synchronized order books.

How does a matching engine distribute market data using UDP multicast?

A matching engine distributes market data using UDP multicast for efficient, low-latency dissemination to subscribers. This approach handles high throughput by broadcasting order book updates without establishing individual network connections.

How do circuit breakers protect a stock exchange matching engine?

Circuit breakers protect a stock exchange matching engine by halting trading to mitigate system instability. They are implemented at order, symbol, and market levels to prevent cascading failures during extreme volatility.

Does this matching engine design work for crypto exchanges?

Yes, this matching engine design works for crypto exchanges. The framework is suitable for both equities and crypto exchanges, addressing high throughput requirements, deterministic matching, and strict latency constraints.

How do I ensure deterministic order matching across replicated nodes?

Deterministic order matching across replicated nodes is ensured by using single-threaded logic and state-machine replication. This guarantees that all nodes process identical sequences of orders to maintain state consistency.