Lesson 0212 min
MARKET · DEPTH · IOC

What Does a Market Order Consume?

Sweep a sell book level by level and separate immediate fills, average execution, and an unmatched IOC remainder.

ObjectivesAfter this lesson, you should be able to:
  • Explain why a market order crosses multiple price levels
  • Use average execution to measure depth impact
  • Explain why an IOC remainder does not become a resting order
COURSE POSITIONStep 2 of 4
  1. PREVIOUSWho Should Fill First?
  2. CURRENTWhat Does a Market Order Consume?

    Sweep a sell book level by level and separate immediate fills, average execution, and an unmatched IOC remainder.

  3. NEXTWho Leaves the Spread Behind?
BEFORE YOU READ

Think about these questions first.

Choose an answer before opening the explanation. You can add anything unexpected to your review list.

Q01Does a market order really mean ‘buy at any price’?
SHORT ANSWER

From a risk perspective, nearly. Real systems often implement it as a protected IOC: consume allowed levels immediately and cancel the rest before an empty or extreme book consumes unlimited funds.

Compared with your prediction:

A market order puts “fill now” first and gives price control to the book. It looks simpler than a limit order but depends more on depth: one request can fill across several levels, so its average price may differ sharply from the first ask you see.

No specified price does not mean no price

The lab’s market order promises only an attempt at immediate execution. It consumes available asks from the best ask upward until the quantity is filled or the book runs out. Every fill still has an explicit price; those prices come from resting sell orders.

ENGINE RUNNINGLAB / credits
ORDERBOOK 001 · PRICE / TIME PRIORITY

LAB / credits

Limit orders enter the queue; only a crossed book turns them into fills.

Last tradecredits / LAB
Best bid98highest buy
Best ask102lowest sell
Spread4ticks
Traded0LAB
MARKET ORDER · IOC

A market order walks the ask levels

It does not write a price into the book; it consumes visible depth immediately. Unfilled remainder does not quietly become a limit order.

Best-ask depth 5 LABLast market average Cancelled remainder LAB
Live order bookPrice / remaining / source
Asks (SELL)Bids (BUY)
1022A
1023B
1055A
983B
965A
Empty
Best ask: 102Best bid: 98
Coach

Read the book first: best ask is the lowest sell, best bid is the highest buy. Matching starts only when buy price reaches sell price.

Engine events1 EVENTS
  1. 01

    Book created: best ask 102 分(两个价位相同's 订单),best bid 98 .price and time priority must be preserved。

ACTION HISTORYExperiment timeline
1 state snapshots

Use the slider to return to an earlier step. Continuing from there replaces the later history with a new sequence.

Initial state
View experiment records →

One order can cross multiple levels

Suppose the ask book has 5 LAB at 102 and another 5 LAB at 105. A market buy for 8 first takes 5 at 102, then 3 at 105. It is not “8 at 102”; it is two fills. Average execution is total notional divided by total filled quantity, so it is above 102 because depth—not a random engine decision—created the difference.

IOC remainder does not quietly join the queue

The teaching implementation uses IOC (Immediate-Or-Cancel): the immediately fillable portion executes, and the rest cancels. “I want to trade now” is kept distinct from “I am willing to wait in the book.”

Expand: how this step works
for ask in asks sorted by price, time:
  fill = min(order.remaining, ask.remaining)
  settle(at=ask.price, quantity=fill)
  if order.remaining == 0: break
cancel(order.remaining)

Real systems also check balances, price protection, risk limits, and matching batches. The lab reports requested, filled, remaining, and average execution so you can inspect state rather than animation.

KNOWLEDGE CHECK

Why is the average execution price above the best ask of 102 after a market buy for 8 LAB?

LESSON RECAPComplete the exercise and knowledge check first