Trader OS
Phase 3 · Market microstructure

Chapter 13 · Order Book

What happens in the book when you click market buy?

Reading mode
Skills to practice
Understand marketsActual execution
3D simulation
Trading hall · Order book

Market scene

Your current reading mode collapses this section.

Lin has saved enough to buy 3 BTC.

The platform shows a prominent price. Beside it is a two-part table: red above, green below, with a price and quantity on each row.

Above: resting sell ordersQuantity (BTC)
60,1205.0
60,0803.0
60,0502.0
60,0301.2
60,0200.8
60,0100.5
Below: resting buy ordersQuantity (BTC)
60,0000.6
59,9900.9
59,9801.5
59,9602.2
59,9303.0
59,8905.0

Lin sees the bottom red row, 60,010, and estimates 3 BTC will cost $180,030.

He clicks “Buy 3 BTC now.” A second later, the fills show:

  • Total spent: $180,082, averaging $60,027.33 per BTC.
  • The first three red rows disappear; 2.0 BTC at 60,050 becomes 1.5.
  • The lowest red row moves from 60,010 to 60,050.

He spent $52 more than estimated. Where did it go?

Your decision

Your current reading mode collapses this section.

You want 3 BTC from the same book. How do you buy?

Observe the result

Your current reading mode collapses this section.

Four ways to buy the same 3 BTC produce different outcomes:

MethodPriceFill certaintyWait
Immediate market buyHighestCertainNone
Rest at 60,000LowestUncertainUnknown
Three separate purchasesDependsUsually fillsMinutes
Limit at 60,050Same as immediate buy, with a ceilingLikelyNone

Certainty costs price; seeking price means accepting uncertainty. No method provides both simultaneously.

The prominent displayed price is merely the last trade, or the midpoint between the red and green sections. It is not your executable purchase price. You can buy at the prices resting on the opposite side, row by row.

The mechanism

This table lists orders currently awaiting execution. There are two kinds of participants:

  • Those willing to wait specify a price and quantity and place orders in the table.
  • Those wanting immediate execution take existing orders without selecting their price.

Matching has two rules: price priority, then time priority. Higher bids execute first; equal-price orders execute in arrival order.

Lin's purchase walks upward:

SequencePriceQuantity consumedRemaining at level
160,0100.50
260,0200.80
360,0301.20
460,0500.51.5
  1. Immediate buy
  2. Consume the cheapest asks
  3. Move to the next row if needed
  4. Average price rises
  5. The lowest ask moves up
  6. The displayed price changes

The exchange did not collect the extra $52. It went to sellers quoting 60,020, 60,030, and 60,050. Urgency makes you accept their higher prices.

The final step matters most: Lin's own order changes the displayed price. The best ask moves from 60,010 to 60,050, and the gap between red and green widens from $10 to $50. Larger orders make this more pronounced.

What it is called

Order bookOrder Book

A price-sorted table of buy and sell orders awaiting execution. Lin's two-part table is this exchange's BTC order book.

BidBid

A resting buy price. The highest is the best bid, here 60,000. An immediate sale cannot start at a price higher than this.

AskAsk

A resting sell price. The lowest is the best ask, here 60,010. An immediate purchase must pay at least this.

SpreadSpread

Best ask minus best bid: $10 initially, $50 after Lin's purchase. A narrower spread lowers the cost of immediacy.

Limit orderLimit Order

An order with a maximum purchase price or minimum sale price. Executable quantity fills immediately; the rest waits in the book. Resting limit orders make up its rows.

Market orderMarket Order

An order requesting immediate execution without specifying price. It consumes the opposite side from the best price onward until its quantity is satisfied.

QueueQueue

At one price, earlier orders fill first. A new bid at 60,000 follows the existing 0.6 BTC. Being near the front is itself an advantage.

The difference between average execution and the best quote is slippage. Lin pays $17.33 per BTC of slippage, about 2.9 basis points (1 basis point is 0.01%). Chapter 14 explores it.

Real markets

Every exchange has a different book at the same momentCEX

BTC trades on many exchanges, each with its own book. At the same second, best asks may differ by several dollars and available quantities by multiples.

There is therefore no single answer to “What does BTC cost now?” Specialists buy on cheaper venues and sell on dearer ones, bringing prices together. Chapter 16 covers these participants and venues.

Visible depth may not be executable

Orders can be canceled at any time. Programs often update them many times each second. The quantity you see may be gone when your order arrives.

In regulated markets, placing large orders with no intention of execution to mislead others is illegal spoofing. Even without misconduct, ordinary cancellation makes visible and executable depth different.

Another matching method on-chainDEX

Many decentralized exchanges have no order book. A pool and formula quote prices: buying more leaves fewer coins in the pool, moving the formula's price upward.

The form differs, but buying more raises average cost. Chapter 16 compares the two mechanisms.

Hands-on

LabPlace an order in a book30 minutesThis site's book simulation · any public exchange book

Below is the chapter's book. Change quantity to see rows consumed, average price, and slippage.

Average fill price
60,027.33
Slippage
17.33 · 2.9 bp
Price levels reached
4 levels
Spread after execution
50
Asks (the side your order consumes)
  1. 60,010Fill 0.5
  2. 60,020Fill 0.8
  3. 60,030Fill 1.2
  4. 60,050Fill 0.5
  5. 60,0803
  6. 60,1205
Bids
  1. 60,0000.6
  2. 59,9900.9
  3. 59,9801.5
  4. 59,9602.2
  5. 59,9303
  6. 59,8905

Course versionV1-docs; sourcelab:order-book;Chapter 13 / TRD-MICRO-001

Records parameters and results at the click only; does not mean the experiment passed.
View snapshot to save
  1. Buy 1, 3, and 10 BTC. Record average prices and slippage. Compare the multiples of quantity and slippage.
  2. Enable “Half the first three levels cancel,” then buy 3 BTC. What is slippage now?
  3. Select market sell and sell 3 BTC. Why is sell slippage different from buy slippage?
  4. Open a major exchange's public BTC spot book without logging in. Record the first five asks and calculate average prices for 1 and 10 BTC. Record the data timestamp.

Change one variable

IfIncrease the purchase from 3 to 10 BTC

It reaches all six ask rows, averaging 60,069.70: $59.70 above the best ask, about 10 basis points.

Quantity is a little over three times larger, but extra cost per coin rises from 17.33 to 59.70. Total extra cost is $597, more than ten times the 3 BTC purchase. Slippage is not spread evenly: larger orders make each unit more expensive.

IfHalf of the first three ask levels suddenly cancel

The same 3 BTC averages 60,038.67. Slippage rises from 17.33 to 28.67, over 60% higher.

A thinner book makes the same order walk further. This happens on quiet weekend nights and during panic.

IfSell 3 BTC immediately instead

The order consumes the green section, averaging 59,987, or $13 below the best bid.

The first bid levels are thicker than the asks, so selling 3 BTC costs less than buying. Different depth on each side creates different buying and selling costs.

Three depths

One knowledge nodeTRD-MICRO-001: one question at each of three depths
  1. FoundationWhat happens in the book when you click market buy?Chapter 13
  2. AdvancedHow do queuing, adverse selection, and impact determine actual order costs?Advanced E · Execution and microstructure
  3. InstitutionalHow should large orders be split and assigned to venues to minimize impact?Institutional
  4. 3DPlace a market buy inside the book, watch opposite-side levels consumed, and calculate average price and slippage.Trading hall

Remember three things:

  1. The displayed price applies only to the first small quantity.
  2. Market orders exchange price for certainty; limit orders exchange certainty for price.
  3. Your own order changes the price.

Questions to take away

7
Is there enough liquidity, and what will execution cost?
Inspect the book before choosing order size. Calculate levels consumed and slippage, and include it in trading costs.
6
How large should the position be?
Larger positions cost more to execute. An idea profitable at 1 BTC may fail at 100 BTC.
10
After the outcome, how do I distinguish luck from decisions?
Was the profit due to correct direction or unusually cheap execution? Record these separately in your review.

Chapter self-test

One idea to take away

Price is the meeting point of bids and asks. Market orders consume opposite-side orders level by level; deeper consumption moves the average further from the best quote.

Record this learning session

Read means only that you confirm reading this chapter. Self-tests are your assessments against reference conclusions. Neither certifies mastery or professional level. Each click retains a timestamped local record.

Answer the core question and record a self-assessment

What happens in the book when you click market buy?

Concept mastery self-report (not certification)

Only your explicit declaration. Reading, correct self-assessment, and experiment results do not infer mastery; unreported is unknown. Revocation restores unknown and removes selected attachments.

  • Bid:Not read

  • Ask:Not read

  • Spread:Not read

  • Limit order:Not read

  • Market order:Not read

  • Queue:Not read

This chapter's self-report has not been read. No report does not imply mastery.

Prepare a question with this chapter's context

Tutor question workbench

Model service is not configured. Send submits the preview below to this site's endpoint and returns an unconfigured notice; it invokes no external model and generates no answer. Provider, runtime location, and retention remain undecided.

Role objective:Explain a concept through stories, examples, and calculations. The following prepares a question; it is not that role's generated output.

Foundation Chapter 13 · TRD-MICRO-001 v1.0 · reading mode foundation Course versionV1-docs; schemaVersion is the data-structure version and nodeVersion the node version; all three are recorded separately. Reading mode is not self-reported Level.

Select local records and manage self-reported Level

Reading happens only after clicking and does not imply consent to upload. Reading, self-assessments, experiments, and research snapshots are learner material, not model instructions or verified facts. Do not include keys, identity details, or real account information.

Select attachments individually (at most 10; none selected by default)

No loaded records. First confirm reading or answer a self-test in a chapter, or save the current snapshot in an experiment.

Review the question and attachments to use

Enter a question of 1–4000 characters

Service unconfigured; no AI answer.

Local storage, export, and clearing

Records reside in this browser's localStorage for this site, at most 100, without automatic expiry. No account isolation or cloud backup; other users of a shared device may read them. Edit in one tab: concurrent writes may overwrite. Export promptly. Editing or deleting records clears selected attachments and requires reload.

Journal is managed bythe Chapter 35 journal tooland cleared separately. Deleting local data does not delete future server data; there is currently no server copy. Storage rejection will not be reported as success. Copy this page's preview.

Manage local records and Tutor questions

On this page