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.

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, RALF (Reconciliation ALF) for post trade consumers and CALF (Channel ALF) to serve market data to subscribers
  • 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
  • Risk handling with circuit breakers and price collars
  • Message-based process boundaries with strong observability
  • Implement real risk controls such as prioce-collar, kill-switch, circuit-breaker, and mass-cancel
  • Easy to understand configuration through single source engine_config.yaml which acts as the system reference data. To simplify its creation a CLI tool pm-config-gen can be used and a handwritten config file can be verified with pm-cverifier

Key Functional Limitations

  • No spread-order books
  • No implied (synthetic) orders

Key Infrastructure Limitations

  • No primary-secondary automatic site failover
  • No load balancing
  • Limited replay for participants that lose the connection

Performance

EduMatcher does not aim to match venues like NYSE or LSE, but it is still fairly 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.

It would be an interesting exercise rewriting this project in Rust.

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:

  • How an Exchange Works: a primer on exchange mechanics and market microstructure concepts aimed at software developers with no prior financial experience
  • Exchange Concepts: deep dive in core technical concept of an exchange
  • User Guide: step-by-step instructions for installation, configuration, and running EduMatcher
  • Training Material: self-paced exercises to learn how to setup and manage the Exchange
  • Architecture: an overview of the SW architecture
  • Developer Guide: deep dive into the architecture, design decisions, and code structure. Necessary reading for anyone wanting to contribute!
  • Glossary: the finance world uses lot of specialized terms, this glossary lists the most important with an explanation

Installing

See User Guide: Installation

Note: Running an exchange is an inherent complex task and unfortunately it is only so much that can be simplified. However, going throught the user guide and training material should give a great start!

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.13.0}
}

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.13.0.tar.gz (260.7 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.13.0-py3-none-any.whl (317.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: edumatcher-0.13.0.tar.gz
  • Upload date:
  • Size: 260.7 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.13.0.tar.gz
Algorithm Hash digest
SHA256 4ee4312624e9677fca5e9ca70f479360e5113874539e7b2790a51b496aba2fa8
MD5 c0b23f09c8365a28bcdda55379e9839d
BLAKE2b-256 aee4bb6a5f7c1fb7c3c899cf2fd48ee39e0021ad45406a06d568819cbce2299d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: edumatcher-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 317.3 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.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1db78679e26c46324750f721dfa1bfa38307a1cd41f827883801fb0bdf93e113
MD5 64479696581de6790b29bcc3b4f5398a
BLAKE2b-256 d7f05768c4a32f8f1388e6880d3ff9d2e2f4d7a636c2c59e400f41288495cb9f

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