Trace: A Market Order Is Executed
The Flow
Trader → Broker → Exchange → Matching Engine → Order Book → Trade Log → ConfirmationStep by Step
-
Trader submits order — A trader's algorithm sends a market order: "BUY 100 shares of AAPL immediately."
-
Broker routes the order — The broker acts as an intermediary, forwarding the order to the exchange via a low-latency network connection.
-
Matching engine receives order — The exchange's matching engine (a high-performance C++ program) loads the order into memory.
-
Engine checks the order book — The engine looks at the ask side (lowest sell orders first):
- Level 1: 100.05 × 30 shares
- Level 2: 100.06 × 200 shares
-
First match — The market order buys all 30 shares at the best ask of 100.05. Remaining: 70 shares.
-
Second match — The market order buys 70 shares at the next ask price of 100.06. Order is now complete.
-
Trade log is written — Two fills are recorded:
- 30 shares @ 100.05 = $3,001.50
- 70 shares @ 100.06 = $7,004.20
- Total: 100 shares for $10,005.70
-
Confirmation sent back — The trader's system receives a confirmation: "BUY 100 AAPL at avg price 100.06."
Key Takeaways
- A market order always fills at the best available prices.
- Large orders sweep through multiple price levels — this is called market impact or slippage.
- The matching engine must be fast — every millisecond matters in high-frequency trading.