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.

Quick Start

Bootstrap a new session directory and either generate engine_config.yaml with sane defaults, or start from the sample config copied by pm-setup:

pm-setup
pm-config-gen --symbols AAPL MSFT --gateways TRADER01 TRADER02 OPS01:ADMIN --sessions-enabled --output engine_config.yaml
pm-engine --verbose

Alternative: skip pm-config-gen and edit the sample engine_config.yaml that pm-setup already placed in your working directory.

If you run from source, prefix commands with poetry run.

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.

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.

Explore the Code

Start with these key areas:

Documentation

Full docs: EduMatcher Documentation

Additional references:

  • How an Exchange Works. This is a generic document meant for SW developers with no previous financial experience. Reading this document will give the necessary background both in finance and the core workings of an exchange.
  • ALF Protocol Appendix. ALF is the Gatewauy human protocol used to send in orders vi the ALF gateway. It is a drastically simplified FIX inspired protocol (ALF = ALmost Fix)
  • Glossary. An extensiv glossary with all commonly used financial terms used in these documents.

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!

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.8.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.8.0.tar.gz (146.3 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.8.0-py3-none-any.whl (174.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: edumatcher-0.8.0.tar.gz
  • Upload date:
  • Size: 146.3 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.8.0.tar.gz
Algorithm Hash digest
SHA256 98e40e1b014f846144b8f1486070d587c47f24d4941852b33e83f2d28573b3de
MD5 ab7a69e1365a8c0f87591d788f82ed05
BLAKE2b-256 c57c5d540779da6e980ad47eef01b408297039073d9d4d288ad00d9c78ca76cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: edumatcher-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 174.7 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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5925b6d50728ea0ac285a9a463d20d1f8cbd30fde647030fddbb67f78a253b8
MD5 c7598ef3e914476e6e0dab498b3e5bcd
BLAKE2b-256 2260193c6a7dabf718e90255c06af4d2494304a0fb7428d87575ef4f2e68d2e7

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