Skip to main content

Educational multi-process trading system with order matching

Project description

EduMatcher

Learn how real trading systems work. Build it from first principles.

Category Link
Package PyPI version Python 3.13+
Documentation Documentation
License License: MIT
Release GitHub release
CI/CD Coverage
Code Quality Code style: black Checked with mypy Linting: flake8
Repo URL GitHub

EduMatcher is an educational trading system that teaches market microstructure, matching logic, and exchange architecture through runnable code.

Unlike toy examples, it is designed to be both understandable and fast.

Why EduMatcher?

  • Real exchange mechanics: order books, auctions, clearing, and risk controls
  • Multi-process architecture: gateway, engine, audit, clearing, stats, and tooling
  • Performance-aware implementation: ~60,000 orders/second with microsecond latency
  • Practical protocol design: ALF (ALmost Fix) command language for gateway order entry
  • Strong engineering discipline: type hints, linting, and high test coverage

Key Features

  • Complete lifecycle: order entry, matching, clearing, and audit trail
  • Rich order support: MARKET, LIMIT, STOP, STOP_LIMIT, IOC/FOK, ICEBERG, combo, OCO
  • Market mechanisms: opening/closing auctions and circuit breakers
  • Config-driven behavior via engine_config.yaml which acts as reference data for EduMatcher
  • Message-based process boundaries with strong observability
  • Implement real risk controls such as prioce-collar, kill-switch, circuit-breaker, and mass-cancel

Key Limitations

  • No spread-order books
  • No implied (synthetic) orders
  • No primary-secondary site failover
  • No load balancing
  • Limited replay for participants that lose the connection
  • No index calculations

Performance

EduMatcher does not aim to match venues like NYSE or LSE, but it is still fast for a pure Python educational project. The figures below reflect the performance on an Intel MacBook Pro. On an ARM M1 MacBook the throughput is roughly 150,000 TPS (an improvement of almost 150%). Latencies are about 25% lower.

Latency (engine-only, n=1,000 each)

Order type min (µs) median (µs) P80 (µs) P90 (µs) max (µs)
Limit 8.1 8.5 9.6 10.0 18
Market 8.1 8.5 8.8 9.3 45

Throughput

Metric Value
Max TPS ~60,000 orders/second
Order mix 20% Market, 30% aggressive Limit, 50% passive Limit

Performance note: price-collar and circuit-breaker checks run in the hot path for every match. They are required for realistic risk control and add measurable cost.

Documentation

Main documentation site EduMatcher Documentation that among other things includes:

  • Installation Guide: how to get up and running with EduMatcher
  • User Guide: step-by-step instructions for installation, configuration, and running EduMatcher
  • Developer Guide: deep dive into the architecture, design decisions, and code structure-
  • Training Materials: self-paced exercises to learn how to setup and manage the Exchange
  • How an Exchange Works: a primer on exchange mechanics and market microstructure concepts aimed at software developers with no prior financial experience

Who It's For

  • Computer science students learning systems design and concurrency
  • Finance students learning market microstructure and trading mechanics
  • Developers building exchange technology or trading systems
  • Anyone curious about how modern markets actually work

Contributing

This is an educational project. If you find bugs, improve the documentation, or make other enhancements PRs are welcome!

Setup a running system

ALTERNATIVE 1: Local Python Installation via pipx

  1. Install Python 3.13+ and Poetry (or use the VM setup below)
  2. Install from PyPI with pipx install edumatcher
  3. Bootstrap a new session directory and either generate engine_config.yaml with sane defaults, or start from the sample config copied by pm-setup:
mkdir session
cd session
pm-setup
pm-config-gen --symbols AAPL MSFT --gateways TRADER01 TRADER02 OPS01:ADMIN --sessions-enabled --output engine_config.yaml
pm-engine --verbose

ALTERNATIVE 2: Using a Multipass VM

Requirements

Requirement Notes
Multipass A lightweight VM manager. Install from multipass.run
curl Used to download the VM bootstrap script
Internet access Required for downloading scripts and PyPI packages
Host resources Recommended minimum: 2 vCPU, 3 GB RAM, 10 GB disk

Bootstrap with one command

curl -fsSL https://raw.githubusercontent.com/johan162/EduMatcher/main/vm/curl_setup_vm.sh | bash -s -- --version 0.12.1 --snapshot

This command downloads the VM setup scripts, launches a Multipass VM, installs EduMatcher in the VM, links all process commands in the exchange pm-* commands into /usr/local/bin, prepares /home/ubuntu/session, and takes an initial snapshot to allow you to easily reset the environment.

Start the CME (Central Matching Engine) in the VM

multipass shell edumatcher-vm
cd /home/ubuntu/session
pm-engine --verbose

Open additional host terminals and run multipass shell edumatcher-vm in each terminal to start pm-gateway, pm-viewer, pm-clearing, and pm-audit.

Note: Running the exchange is complex enough that you really need to read the documentation and follow the instructions in the User Guide to get a full exchange up and running. The above commands are just a quick start to get you going. The User Guide will explain how to configure the exchange, start and stop processes, and run the system in a realistic way.

Citation

If you use this tool in teaching or courses, please cite:

@software{edumatcher,
  title = {EduMatcher},
  author = {Johan Persson},
  year = {2026},
  url = {https://github.com/johan162/edumatcher},
  version = {0.12.1}
}

License

MIT License - see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edumatcher-0.12.1.tar.gz (228.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edumatcher-0.12.1-py3-none-any.whl (277.1 kB view details)

Uploaded Python 3

File details

Details for the file edumatcher-0.12.1.tar.gz.

File metadata

  • Download URL: edumatcher-0.12.1.tar.gz
  • Upload date:
  • Size: 228.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1018-azure

File hashes

Hashes for edumatcher-0.12.1.tar.gz
Algorithm Hash digest
SHA256 9f21e11b46d659992249a966435574eb5899cd2b7d32b195c9b2b8395a5db214
MD5 2966882a3b026bfc2f3daa983783b826
BLAKE2b-256 88e1fe5770e556aad8865f4285172301bd4e2a84a43acb4b0d46d652ef35897e

See more details on using hashes here.

File details

Details for the file edumatcher-0.12.1-py3-none-any.whl.

File metadata

  • Download URL: edumatcher-0.12.1-py3-none-any.whl
  • Upload date:
  • Size: 277.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1018-azure

File hashes

Hashes for edumatcher-0.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24a24545330341729e43fe027029377304695a5cca5a77be0f62ec6c24408c70
MD5 3d55af23cbe27cf7b070984eeee9b65b
BLAKE2b-256 304e191b379a3c5ae6223df244277a5145af1e037ca327afb7b05349198eb7a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page