Traders send orders to buy or sell one stock. A matching engine keeps the waiting orders in a list called the book, best price first. It makes a trade when a buyer and a seller agree on a price. There are two engines: a main one and a backup. Send a big order, or turn off the part that puts orders in one line, and watch what changes.
Try it
Speed
Lab time 3.0 s
Traders — 12 orders a second — healthy — 38 sent
Order gateway — takes each order in — healthy — then passes it on
Sequencer — numbers every order — healthy — next number 38
Main engine — 15 trades — healthy — best $95 buy, $96 sell
Backup engine — 15 trades — healthy — the same book
An order from a trader
The order on its way to the engines
Last trade
$96
15 trades, 430 shares
Best buy and sell
$95 / $96
$1 apart
Orders waiting
21
1,190 shares in the book
Last big order
–
press a "500 at any price" button
Matched differently
0/ 37
orders the two engines did not match alike
Backup engine's book
the same
as the main engine's, order for order
Numbers add up:2,050 shares placed = 1,190 waiting + 0 cancelled + 2 × 430 tradedThe lab checks this sum as it runs, so a counting mistake would show here.
Controls
Orders waiting
Side
Place in line
Price
Shares
From
Waiting for
Sell
6
$99
70
trader 29
0.4 s
Sell
5
$99
80
trader 7
2.3 s
Sell
4
$98
20
trader 86
1.9 s
Sell
3
$97
80
trader 36
1.1 s
Sell
2
$97
70
trader 92
1.6 s
Sell
1
$96
10
trader 86
0.4 s
Buy
1
$95
80
trader 76
1.8 s
Buy
2
$94
70
trader 67
1.2 s
Buy
3
$93
40
trader 15
2.3 s
Buy
4
$93
10
trader 35
1.6 s
Buy
5
$93
30
trader 17
1.5 s
Buy
6
$93
40
trader 62
1.1 s
The first 6 sell orders and the first 6 buy orders in line. Place 1 on each side trades next: the lowest sell price, and the highest buy price.
Last trades
When
Price
Shares
Order that arrived
2.8 s
$96
40
trader 86
2.7 s
$96
40
trader 73
2.3 s
$97
30
trader 70
2.3 s
$96
40
trader 70
1.9 s
$97
10
trader 53
1.9 s
$96
30
trader 53
1.9 s
$95
10
trader 67
1.9 s
$95
20
trader 67
Price of the last trade, with the best buy and sell prices ($)
Last tradeBest buyBest sell
0501001502001s2s3s
Show data table
Time
Last trade
Best buy
Best sell
1s
100
96
—
1s
96
96
99
2s
96
96
97
2s
97
95
97
3s
97
95
97
3s
96
95
96
What just happened
Nothing yet. Start traffic or run an experiment.
What this model simplifies
There is one stock, and prices are whole dollars. A real exchange has thousands of stocks, each with its own book, and prices in cents.
Nine orders in ten are limit orders, which name a price. One that nobody takes is cancelled after 15 s. Real traders cancel and change orders all the time.
One trip over the network takes 40 ms, and the last trip to an engine up to 60 ms more. A real exchange measures these trips in millionths of a second, but they still differ.
The backup takes the same orders as the main engine and stays ready. This model never fails over to it; it only shows whether it could. Keeping two engines alike by giving them the same orders in the same order is called state machine replication.
There are no checks on a trader's money or shares, and no fees. A real gateway refuses an order the trader cannot pay for.
The sequencer is one part and never stops here. In a real exchange it is the part that must never be lost, so it has its own backups.