Not a toy.
A venue.
51 commands, a brokerless message bus, five order-entry and data protocols, auctions, risk controls, clearing and an audit trail. This is what is running when you start EduMatcher.
Processes, not
functions
Real exchanges are fleets of cooperating services. EduMatcher is built the same way: each process owns its state, talks only by message and can run on a different machine.
- Brokerless ZeroMQ — PUSH/PULL for commands, PUB/SUB for events. The engine is the only process that binds.
- Private replies over PUB/SUB — acks and fills ride topics only the sender subscribes to.
- Add an observer without touching the engine — audit, clearing and market data are all just subscribers.
- Persistence & recovery — SQLite stores, restart-safe, with an audit replay tool.
engine sockets: commands in, events out, drop-copy out
installable pm-* commands
brokers or external services required
YAML file as the single source of reference data
Every order type a trader expects
From the simplest market order to multi-leg strategies — with the semantics real venues apply: when stops trigger, how icebergs refill, what a fill-or-kill checks before it fires.
MARKET · IOC · FOK
Execute now against resting liquidity. FOK pre-checks the whole quantity, including hidden iceberg reserve, before it fires.
LIMIT · ICEBERG
Rest at a price. Icebergs show only a visible peak and refill from hidden reserve, losing queue position like the real thing.
STOP · STOP_LIMIT · TRAILING
Triggered by trades, in deterministic order: stops first, then trailing stops, each in arrival order.
ATO · ATC
At-the-open and at-the-close orders live only in their auction and expire when it uncrosses.
OCO · COMBO
One-cancels-other pairs and coupled combo orders that manage multi-leg exposure.
Market-maker quotes
Two-sided quotes with bootstrap, per-symbol management and a bundled bot that keeps every book alive.
Self-match prevention
Configurable per gateway and per order, so a participant cannot trade with itself.
AMEND · CANCEL · mass cancel
Amendments that respect or reset time priority exactly as documented; mass cancel by participant.
# a 1000-share iceberg that shows only 100 at a time NEW|SYM=AAPL|SIDE=BUY|TYPE=ICEBERG|QTY=1000|PRICE=150.00|VISIBLE=100
A trading day with auctions
Exchanges do not simply match from the first second to the last. A scheduler walks every symbol through pre-open, opening auction, continuous trading and a closing auction — with equilibrium-price uncrossing and imbalance published as it goes.
Why auctions?
They concentrate liquidity and neutralise speed advantages at the open and close — the two moments when a reliable price matters most.
Calendar-aware
Weekday-specific schedules, a country holiday calendar and a time zone. The scheduler can run daily for weeks.
Visible to everyone
TapeDeck shows session state, recent auction results, imbalance and active halts live.
Take a company public
Every listed stock was once a private company with a story and a spreadsheet. With pm-valuation your students value a fictive company, build the book, set the offer price, and list it. Then their classmates' orders in the opening auction show whether they got it right.
A valuation you can
check with a calculator
A banker's model is usually a black box. Here every number can be traced back to where it came from. A full-screen interview asks about the market, customers, churn, people, costs, capital and discount rates. Each answer is marked you, preset, derived or default, and the live preview recalculates fair value as you type.
- Two-stage DCF: ten years of free cash flow, CAPM discount rates with size and execution premia, and a terminal value in which growth has to be paid for.
- Comparables: EV / revenue from the sector, blended 70/30 with the DCF, with a warning when the two methods disagree.
- Uncertainty in plain sight: bear, base and bull cases, a tornado of the drivers that matter, and a 10,000-company Monte Carlo that gives the odds the offer price is too high.
tornfalk classroom case, straight from the reportHard finance
Time value of money, risk premia, free cash flow and the bridge from enterprise value to a price per share. Given the same assumptions, everyone gets the same answer.
- Fair value 117.45 SEK
- Price range 94.50–105.00 SEK, after a 15 % IPO discount
- P(overpaying) 43.8 % of simulated companies
Market mood
Investor interest, hype and a coverage target are modelled as clearly labelled heuristics, so students can see which way each force pushes the price.
- Book 11.92× covered at the maximum price
- Expected pop 29.8 % on the first day
- Money left on the table about 1.2 bn SEK
Same seed, same answer
The Monte Carlo is seeded (42 by default), so a whole class gets identical results. Change the seed to see how much the result moves by chance alone.
Scenario files
Save with F9 and only your own answers are written. --with-defaults writes a fully specified case, with every value commented with its source, ready to hand out to the next group.
Back, change, compare
Go back to the interview, change one answer, press F5 and compare. Turn the hype down and the valuation stays put while coverage and the pop collapse.
18 sector presets
From SaaS and medtech to retail, heavy industry and wind parks. Each is a coherent set of margins, churn, capex, beta and multiples, with its ICB and SIC code.
Stockholm or New York
A Swedish prospectus approved by Finansinspektionen, where the top of the range is a hard maximum price, or a US S-1 with --market us, which may price up to 20 % outside the range.
A prospectus-style PDF
Cover, executive summary, six chapters with figures, every assumption and a glossary. --pdf writes it, or press p in the report.
From zero to
book-runner
The Operator's Guide teaches the finance from scratch, from compounding to the growing perpetuity, with worked examples you can check by hand. The Training Guide then has seven exercises built around two shipped cases. Tornfalk is a hot software deal. Halvard is a robotics IPO that has to be postponed, because management will not price below the last private round.
$ pm-valuation --case tornfalk # interview, F5 for the report $ pm-valuation --case tornfalk --no-tui --pdf tornfalk.pdf $ pm-valuation --case halvard --no-tui # POSTPONE: why? # price it, list it, let the market decide $ pm-opctl-cli stop $ pm-valuation --case tornfalk --no-tui --mode deterministic --list $ pm-opctl-cli start
A teaching model, not a pricing engine: presets and sentiment formulas are illustrative and clearly labelled. The first real price is set by the opening auction.
Defence
in depth
Controls run in the hot path for every order and every match — and they are measured: the benchmark figures include them.
- Price collars — static and dynamic, per symbol or exchange-wide.
- Circuit breakers — three market-wide levels modelled on real venues.
- Automated Collar Expansion — the reopening call widens its corridor step by step, modelled on Xetra, until it can uncross.
- Operator override — kill switch, mass cancel, symbol halts and resumes.
- Health monitoring — thresholds on loop lag and heartbeat raise alerts in the dashboard.
Speak to it in six dialects
EduMatcher defines its own readable protocol family — the ALF family, “ALmost Fix” — and documents every message. Write a client in any language over plain TCP.
| Protocol | Purpose | Format | Served by |
|---|---|---|---|
| ALF | Human-readable order entry and gateway control | Text lines, FIELD=VALUE|… | pm-alf-gwy · pm-alf-console |
| BALF | Low-latency order entry for programs | Binary frames, fixed-point i64 prices | pm-balf-gwy |
| CALF | Market data: top of book, depth, trades, state, index | Text over TCP, snapshot + incremental, sequence-aware | pm-md-gwy |
| RALF | Post-trade for clearing, drop-copy and audit roles | Text over TCP, replay-aware reconnect | pm-ralf-gwy |
| LALF | Centralised process logging | Text over TCP | pm-log-srv |
| REST · WebSocket | Order entry, history and live events for browsers and tools | JSON over HTTP + WS, Swagger docs at /docs | pm-api-gwy |
| DC1 | Plain-TCP view of the drop-copy fill feed | Text lines | pm-dc-gwy |
Protocol spy tools — pm-calf-spy, pm-ralf-spy, pm-dc-spy — let you watch any feed on the wire while you learn it.
Run it like you would run one
Configure once
A single engine_config.yaml defines symbols, participants, sessions, risk and gateways. Edit by hand, generate with pm-config-gen, or build it in the Configuration GUI; lint with pm-cverifier; deploy with pm-config-deploy.
List new symbols
Add instruments at runtime with pm-new-symbol and run an IPO with pm-valuation to derive a sensible opening price.
Observe everything
Central structured logs, health beacons from every process, a monitor and the Operator Dashboard. pm-log-cli, pm-monitor-cli and pm-audit-cli for the shell.
Audit & replay
Every engine event is written to the audit trail; pm-audit-replay re-runs history for verification and teaching.
Deploy
Container images for the engine and each GUI, a Compose bundle, a one-line installer, a VM runtime image with a pinned release, or plain pipx.
Multi-host ready
Internal buses bind to loopback by default; external gateways bind to the network. Put the pieces on different machines when you want to.
Written like it
might matter
An educational code base is only as good as its worst example. EduMatcher is held to production-style standards, so what you learn from it is worth learning.
- 8700+ tests across 186000+ lines of source, with a deterministic verification harness for the matching engine.
- Static typing & linting — type hints throughout; black, flake8 and mypy gate every change in CI.
- Documented design decisions — complexity of every core operation, failure modes such as ZeroMQ back-pressure, and the trust model.
- One message specification —
pm-msgengenerates the Python (and C) bindings for 120+ messages, byte-for-byte deterministic, so docs, code and wire never drift.
$ pm-help # every command, grouped $ pm-config-show -a # resolved config, ports, API keys $ pm-cverifier engine.yaml # lint a configuration $ pm-alf-console # trade from the terminal $ pm-viewer -s AAPL # live order book $ pm-audit-replay # replay history
What it deliberately leaves out
EduMatcher keeps the parts of an exchange that matter for learning and simplifies the rest. These are the limits, stated up front.
The Reference Manual keeps the full, current list of known limitations.