Equity trading infrastructure · v0.77.0

A real exchange.
Built to be understood.

EduMatcher is a complete trading venue — matching engine, auctions, risk controls, clearing, market data, audit trail and six browser applications — written in readable Python, so you can run it, watch it and take it apart.

$curl -fsSL https://raw.githubusercontent.com/johan162/EduMatcher/main/deployment/curl/install.sh | bash
Docker or PodmanPython 3.14+MIT licensedNo toy order book
Market depth · EDUillustrative
150.32+0.00
BID QTYPRICEASK QTY
51
Commands & processes
6
Browser applications
6
Wire protocol families
186,000+
Lines of Python
8,700+
Automated tests
8
Guide books
Two things at once

Educational on purpose.
Not a toy by any measure.

Most teaching exchanges are a single script with a sorted list. EduMatcher is the opposite: the whole venue, as separate processes talking over real protocols — with the books and tooling to learn every part of it.

// for learning

Made to be read

  • Plain Python — no C extensions in the matching path, no magic; step through any order in a debugger.
  • 8 guide books from a quick start to protocol specifications and a guided code tour — plus a separate general introduction to exchanges for readers new to finance.
  • 29-chapter training guide with hands-on exercises, plus slide decks for instructors.
  • An exchange that trades itself — 100 AI traders keep 300 symbols alive for your class.
  • Observable by design — every process logs, every event is on the bus, every fill is audited.
// for real

Built like a venue

  • Multi-process ZeroMQ architecture — engine, gateways, clearing, audit, statistics, scheduler, monitor.
  • Full order set — market, limit, stop, stop-limit, trailing stop, IOC/FOK, iceberg, combo, OCO, mass quotes.
  • Auctions & risk — opening/closing auctions, price collars, circuit breakers with collar expansion, kill switch.
  • Real interfaces — text, binary, market-data, post-trade, REST and WebSocket protocols.
  • Operations — health monitor, audit replay, persistence and recovery, containers, one-line install.

The one honest difference: it is written in Python. It will not rival C++ and FPGA venues on raw speed — and that is exactly why you can read it.

Anatomy of a venue

Every part of a real exchange,
as its own process

A brokerless ZeroMQ bus ties them together. The engine is the only process that binds sockets; everything else — gateways, clearing, audit, market data — is just a client of the bus, exactly like the colocated services of a production venue.

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
Six windows on one exchange

Trade it. Watch it.
Operate it.

Six browser applications and a full set of terminal tools all talk to the same running exchange. Place an order in one — see it on the others within a second.

pm-trading-ui · :8093

A real trading workstation

Candles, a live depth ladder, an order ticket with eight order types and a blotter — plus market-maker quote management and, for operators, halts, circuit breakers and the kill switch.

  • Market, limit, stop, stop-limit, FOK, iceberg, IOC, trailing stop
  • Role-based screens: trader, market maker, admin
  • API-key login; talks to the exchange over REST + WebSocket
localhost:8093 — Trading Workspace
Trading GUI workspace: price chart, depth ladder, order ticket and working orders
pm-terminal · :8090

TapeDeck: the classroom wallboard

All 300 symbols in a live market overview, plus symbol detail, index, tape, movers, session status with halts and auction results, and the news feed.

  • Read-only — safe to put on a projector
  • Live CALF market-data feed, sequence-aware
  • Auction equilibrium prices and halts at a glance
localhost:8090 — Market overview
TapeDeck market overview with 300 symbols, bid/ask and volume
pm-book · :8094

Order Book Viewer

One symbol, every price level: bids, asks, depth bars, the trade tape and session OHLC. Watch an iceberg refill or an auction uncross as it happens.

  • Full depth with order counts per level
  • Trade tape with aggressor colouring
  • The browser companion to pm-viewer
localhost:8094 — MSFT
Order book viewer showing bids, asks and trades for one symbol
pm-dash · :8095

Operator Dashboard

The exchange's vital signs: process health, CPU, memory, loop lag, orders and trades per minute, reject ratio and participant connectivity.

  • Every process with sparkline CPU and RSS
  • Engine P99 latency and throughput
  • Drill into a process for its recent history
localhost:8095 — Overview
Operator dashboard with gauges, process table and memory chart
pm-log-ui · :8091

Log Operator Console

Every process ships structured logs to a central server. Search, filter, follow live, acknowledge alerts and inspect connections and diagnostics — the answer to “why was my order rejected?”.

  • Live tail with level and text filters
  • Alerts you can acknowledge
  • Connection and health views
localhost:8091 — Logs
Log console with live structured log lines and a detail panel
config-gui · :8092

Configuration Builder

Design a whole venue with forms instead of YAML: symbols and reference prices, sessions and holidays, risk collars, circuit breakers, market makers, indices — validated as you type.

  • Live diagnostics and an export gate
  • Import, review and diff existing configs
  • Light and dark themes
localhost:8092 — Basics
Configuration GUI with symbol table and diagnostics panel
From order to trade

Follow one order
through the venue

A NEW order is parsed by a gateway, risk-checked, matched with price-time priority, and then fanned out on the bus to clearing, audit, statistics, market data and every screen you have open.

  • Heaps and price-level indexes with lazy deletion — complexity documented for every operation
  • Pre-trade collar and circuit-breaker checks in the hot path
  • Every step observable: topics, acks, fills, rejects
The life of one limit order 1 Client sends an ALF line NEW|SYM=AAPL|SIDE=BUY|TYPE=LIMIT|QTY=300|PRICE=150.35 2 Gateway authenticates & parses ID checked · parsed into an engine request 3 Engine pulls & risk-checks tick · collar · breaker · session phase 4 Matched with price-time priority ASKS 150.37 · 400 150.35 · 300 ← crosses TRADE 300 @ 150.35resting order keeps its priceaggressor takes the rest, or rests 5 Acks and fills go back — privately on a topic only the sender subscribes to 6 …and the world finds out stats clearing audit market data screens
Fig. One limit order, end to end. The ALF line is the real wire format; the engine path is described in the Architecture book.
An exchange that trades itself

A market with
nobody at the desks

An empty exchange teaches nothing. EduMatcher ships a simulation: 100 AI traders, each with a simple rule of its own, trade 300 symbols all day — chasing a hidden true value that jumps when news breaks and wobbles when rumours spread.

  • Value investors, trend followers, noise traders, news reactors
  • Public headlines, secret values — price discovery you can watch
  • One container, runs for weeks, accelerated time for lectures
━ market price╌ hidden true value▏news jumps the value; price follows
■ buying■ selling□ waiting — the 100-trader swarm, live
What is inside

The unglamorous parts, too

The parts of an exchange nobody puts on a brochure are the parts that make it real.

Order book & matching

Price-time priority, partial fills, iceberg refills, stop triggers in deterministic order, self-match prevention, amend semantics that respect priority.

Sessions & auctions

A scheduler with holiday calendars drives pre-open, opening auction, continuous trading, closing auction and close. Equilibrium-price uncrossing with imbalance.

Risk controls

Static and dynamic price collars, three-level market-wide circuit breakers, automated collar expansion on reopening, kill switch and mass cancel.

Market makers

Two-sided quotes and a bundled market-maker bot keep books liquid; quote management lives in the Trading GUI.

Clearing, P&L & audit

Positions and P&L per participant, a durable audit trail of every event, and a replay tool to re-run history against the engine.

Indices & statistics

A real-time cap-weighted index, session statistics in SQLite, movers, tape and news — all published to external consumers over CALF.

Protocols & APIs

ALF text and BALF binary order entry, CALF market data, RALF post-trade, LALF logging, DC1 drop-copy, plus a documented REST and WebSocket API.

Health & observability

Every process emits a heartbeat beacon; the monitor derives health, lag and alerts. Central structured logging feeds the console.

Deploy anywhere

One-line container install, a pinned-release VM image, or pipx install edumatcher. Multi-host ready: internal bus on loopback, gateways on the network.

Honest numbers

Fast for Python.
Open about the rest.

EduMatcher does not try to match NYSE or LSE. It was measured, though — with price-collar and circuit-breaker checks switched on, because those are what a real engine pays for.

Why Python? Because a matching engine you can read in an afternoon teaches more than one you cannot. Production venues use C++, Java or hardware and are orders of magnitude faster; EduMatcher trades raw speed for clarity — and keeps the architecture honest.
Median engine latency (limit order)49.7 µs
P90 latency53.2 µs
Mean cost per order34.3 µs
Sustained throughput~29,122 orders/s

Mix: 20 % market, 30 % aggressive limit, 50 % passive limit. engine-only, risk checks enabled (price collar + circuit breaker), high-end Linux server. Bars are for visual scale only.

Cover of Exchange Concepts: An Introduction
Also in the library · not about EduMatcher

Exchange Concepts: An Introduction

A general introduction to how financial exchanges work: order books, matching, auctions, risk, clearing and market data. It is written for readers who are not finance experts — software developers included — and explains the ideas every exchange is built on, whichever software runs it.

  • General, not product-specific: it does not document EduMatcher. Read it before the guide books, or alongside them whenever a market term stops you.
  • 46 chapters in four parts: markets and participants; orders, matching and the trading day; risk, clearing and compliance; technology and market ecology.
  • Real-world grounding: a tour of real exchanges, historic notes and cautionary tales such as Knight Capital.
Edition 1.10.1PDF · EPUB · by partquizzes included

The edition number follows its own scheme and is independent of the EduMatcher version (v0.77.0).

Version 0.77.0 · MIT licensed

Start your own exchange
in the next five minutes

One command, a running venue, six web apps. Fork it, break it, extend it — the whole source is on GitHub.