EduMatcher / Platform
The system

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.

Architecture

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.
3

engine sockets: commands in, events out, drop-copy out

51

installable pm-* commands

0

brokers or external services required

1

YAML file as the single source of reference data

EduMatcher process architecture Clients connect through ALF, BALF and API gateways to the matching engine. The engine publishes every event on a ZeroMQ bus read by internal services and by external dissemination gateways. PARTICIPANTSGATEWAYS THE BUS FANS OUT Trader consolepm-alf-console · local Bots & AI swarmpm-mm-bot · pm-ai-swarm Your own programsany language · TCP / HTTP Browser appsTrading GUI · TapeDeck Operatorspm-admin · pm-opctl-cli ALF · textpm-alf-gwyTCP :5565 BALF · binarypm-balf-gwyTCP :5560 REST · WebSocketpm-api-gwyHTTP :8080 pm-scheduleropen · auctions · close MATCHING ENGINE pm-engine PULL :5555 ◂ cmdsPUB :5556 ▸ eventsPUB :5557 ▸ dropcopy · price-time order books · auctions, uncrossing · collars & breakers · stops, icebergs · sole socket binder pm-market-simtrue values · news ZEROMQ PUB / SUB INTERNAL SERVICES pm-statsstats pm-clearingP&L pm-audittrail pm-indexindex pm-monitorhealth pm-log-srvLALF :5600 pm-viewer · pm-board · pm-tickerterminal EXTERNAL GATEWAYS CALF · market datapm-md-gwy:5570 RALF · post-tradepm-ralf-gwy:5580 DC1 · drop-copypm-dc-gwy:5590 WebSocket eventspm-api-gwy:8080 → vendors · clearing · risk · compliance
commands inevents outHover a box to follow its connections
Order handling

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.

Aggressive

MARKET · IOC · FOK

Execute now against resting liquidity. FOK pre-checks the whole quantity, including hidden iceberg reserve, before it fires.

Passive

LIMIT · ICEBERG

Rest at a price. Icebergs show only a visible peak and refill from hidden reserve, losing queue position like the real thing.

Conditional

STOP · STOP_LIMIT · TRAILING

Triggered by trades, in deterministic order: stops first, then trailing stops, each in arrival order.

Auction

ATO · ATC

At-the-open and at-the-close orders live only in their auction and expire when it uncrosses.

Multi-leg

OCO · COMBO

One-cancels-other pairs and coupled combo orders that manage multi-leg exposure.

Liquidity

Market-maker quotes

Two-sided quotes with bootstrap, per-symbol management and a bundled bot that keeps every book alive.

Safety

Self-match prevention

Configurable per gateway and per order, so a participant cannot trade with itself.

Lifecycle

AMEND · CANCEL · mass cancel

Amendments that respect or reset time priority exactly as documented; mass cancel by participant.

ALF · text order entry
# 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
Market structure

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.

A trading day as session phases EXAMPLE SCHEDULE · CONFIGURABLE PER WEEKDAY PRE_OPENorders rest · no match OPENINGAUCTIONATO · uncross CONTINUOUSprice-time priority · every order matches on arrival CLOSINGAUCTIONATC · uncross CLOSEDorders rejected 09:0009:2509:3016:0016:05 circuit breaker halt reopening auction with collar expansion

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.

IPOs & valuation

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.

From a private company to its first trade: the eight steps pm-valuation and the exchange walk through THE SCIENCE · VALUE THE COMPANY THE BLACK MAGIC · SELL IT THE MARKET DECIDES 1 · INTERVIEW 12 pages18 sector presets4 levels 2 · FORECAST 10 yearscustomers · churncosts · FCFF 3 · VALUE 2-stage DCF+ comparables= fair value 4 · DOUBT IT bear · bulltornadoMonte Carlo 5 · BOOK-BUILD price rangedemand · hypecoverage 6 · VERDICT PROCEEDor POSTPONEoffer price · pop 7 · LIST pm-new-symbolreference priceseed quote 8 · THE OPEN openingauctionstudents' orders pm-valuation runs steps 1–6 without an exchange · --list hands the priced IPO straight to step 7
Show your working

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.
Valuation football field for the Tornfalk classroom case, in SEK per share TORNFALK SECURITY AB · SEK PER SHARE 050100150200250300 Bear → bull Monte Carlo DCF Comparables Price range 16.94307.41 P5 58.53P95 174.18 92.09 176.62 94.50–105.00 fair value 117.45 offer 105.00
Football field · the tornfalk classroom case, straight from the report
The science

Hard 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
The black magic

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
Repeatable

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.

Shareable

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.

What-if

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.

Realistic

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.

Two frameworks

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.

Printable

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.

In the classroom

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.

terminal
$ 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.

Risk controls

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.
Defence in depth: the gates an order passes before it can trade 1 · STATIC COLLAR±20 % of reference — outside rejected 2 · DYNAMIC COLLARband around the last trade price 3 · CIRCUIT BREAKERSL1 7 % · L2 13 % · L3 20 %the highest level crossed fires → halt 4 · REOPENING AUCTION + ACEcollar widens until the call uncrosses OPERATOR OVERRIDEkill switch · mass cancel · admin halts
Wire protocols

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.

ProtocolPurposeFormatServed by
ALFHuman-readable order entry and gateway controlText lines, FIELD=VALUE|…pm-alf-gwy · pm-alf-console
BALFLow-latency order entry for programsBinary frames, fixed-point i64 pricespm-balf-gwy
CALFMarket data: top of book, depth, trades, state, indexText over TCP, snapshot + incremental, sequence-awarepm-md-gwy
RALFPost-trade for clearing, drop-copy and audit rolesText over TCP, replay-aware reconnectpm-ralf-gwy
LALFCentralised process loggingText over TCPpm-log-srv
REST · WebSocketOrder entry, history and live events for browsers and toolsJSON over HTTP + WS, Swagger docs at /docspm-api-gwy
DC1Plain-TCP view of the drop-copy fill feedText linespm-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.

Operations

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.

Engineering

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-msgen generates the Python (and C) bindings for 120+ messages, byte-for-byte deterministic, so docs, code and wire never drift.
terminal
$ 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
Straight talk

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.

Speed. Roughly 29,122 orders/s and ~49.7 µs median engine latency, in Python. Real venues are far faster.
Authentication. Participants are identified by configured IDs and API keys; there is no member/firm/user hierarchy.
Fault tolerance. One machine runs the exchange; no hot standby, replication or failover.
Instruments. Equities only. No implied (synthetic) orders; combos are coupled order books rather than a book of their own.

The Reference Manual keeps the full, current list of known limitations.

Seen enough? Run it.