Aperiodic/Markets from First Principles
Markets from First Principles/Part 2, Pushing and paying

Lesson 5 of 10

Walking the book

What does it cost to buy more than the best ask holds?

DMBy Daniel and Mark
11 min

So far: A five-minute candle keeps four prices and a volume, and many different runs of trades leave the same one: their sizes, their order and every step the price took are gone (lesson 4).

Past the best ask

In lesson 1 you bought one sack from the cheapest note to sell, and the next buyer paid a little more. Now buy more than the best ask holds. The rest of your order doesn't wait: it takes the next cheapest price, then the next, until it is filled. Traders call this walking the book.

Here is a deeper book, with toy numbers: a unit costs about 100 coins, and prices move one tick, 0.01, at a time. Each column is one level, as tall as the units waiting there: bids on the left, asks on the right, 25 levels of asks in all. Pick a size and send your order.

Step 1 of 3

Pick an order size and send it. Watch it take the asks level by level, and see where its average price lands.

mid
99.95100.00100.05100.10100.15100.20
40

Nothing sent yet. The best ask holds 10 units at 100.00. Send 40 units and see how far up the book they reach.

An order of 40 takes all 10 units at the best ask, then 6 at 100.01, 8 at 100.02, 6 at 100.03, 8 at 100.04 and the last 2 at 100.05. Each fill is a trade of its own, at its level's price. They average 100.0205, which is 2.05 basis points over the best ask. That difference is the order's ƒslippage.

Slippage is measured from the best price you could see when you sent the order: the best ask for a buy, the best bid for a sell. An order the best level can hold has none. Double the order to 80 units and the slippage more than doubles, to 4.48 basis points. Paid on twice as many units, the extra over the best ask comes to more than four times as much: 3.58 coins against 0.82.

The maths

An order of Q units fills q1 at p1, q2 at p2, and so on:

average price = (q1 · p1 + q2 · p2 + …) / Q

slippage of a buy, in bps = (average − best ask) / best ask × 10,000

slippage of a sell, in bps = (best bid − average) / best bid × 10,000

Thin and thick

How far an order walks depends on how much waits at each level. A book with plenty at every price is called deep, or thick, and one with little is thin. The figure sets the book from above next to one with half as much at every level. Move your order and compare.

Step 2 of 3

Drag the order size. Compare what the same order pays on a thick book and on a thin one.

Thick book
average
100.00100.05100.10100.15100.20
Thin book, half at every level
average
100.00100.05100.10100.15100.20
051015bps050100150 unitsthickthin
40
Live: 40 units on each book
Slippage, thick
2.05 bps
Slippage, thin
4.48 bps
Levels, thick
6
Levels, thin
10

With half as much at every level, the same 40 units walk 10 levels instead of 6, and pay 4.48 basis points instead of 2.05: 2.2 times as much.

Halve the depth and the slippage roughly doubles. At 40 units the thin book charges 4.48 basis points against the thick book's 2.05, and the order walks 10 levels instead of 6. The thick book's line also bends: past 118 units the order reaches the wall of 40 units at 100.13, and the line flattens, because every unit in the wall costs the same.

So a trader who needs to buy a lot can split the order and send the pieces minutes apart, and each piece meets a book that has had time to refill. Whether it refills, and at what price, is the next lesson.

Which side is heavier

Lesson 2 compared the queues at the best bid and the best ask. With 25 levels a side you can ask the same question at any depth: add up the first 5 levels of each side, or 10, 20 or 25, and compare. The ƒbook imbalance is the difference over the total. It runs from −1 when only asks wait to +1 when only bids do.

Step 3 of 3

Add up the first 5, 10, 20 or 25 levels on each side. Watch which side comes out heavier.

mid
99.7599.8099.8599.9099.95100.00100.05100.10100.15100.20
bids 60asks 38
Live: The first 5 levels of each side
Bids
60 units
Asks
38 units
Imbalance
+0.22
Heavier side
bids

Near the price the bids are heavier. The next small trades meet these levels first.

In this book the answer depends on how far you look. On the first five levels the bids are heavier, 60 units against 38, an imbalance of +0.22. Across all 25 levels the asks hold twice as much, 312 against 156, an imbalance of −0.33. Both readings are right, and they answer different questions. The first levels are what the next small trades will meet. The deeper ones are what a large order would meet, and they are further from trading: whoever placed them can move or cancel them before the price gets there.

The maths

Over the first N levels of each side, with B units of bids and A units of asks:

imbalance = B − A, imbalance ratio = (B − A) / (B + A)

In real data

Bitcoin's book, 25 levels deep

First levelsBidsAsksImbalance ratio
57.29 BTC7.85 BTC−0.038
107.41 BTC8.16 BTC−0.048
207.61 BTC8.55 BTC−0.059
257.69 BTC8.67 BTC−0.060

At the end of the five minutes from 14:00 UTC on 14 May 2025, 7.29 bitcoin waited on the first five bid levels of Binance's bitcoin perpetual, and 7.85 on the first five ask levels. Going out to 25 levels added only 0.40 to the bids and 0.82 to the asks: more than nine tenths of what waited within 25 levels sat in the first five. A buy of more than 7.85 BTC, about $0.82 million, would have walked past the fifth level into a much thinner book.

The asks were heavier at every depth, and a little more so further out: the imbalance ratio was −0.038 on five levels and −0.060 on 25. Here the near and far levels agreed.

Over the same five minutes the median trade paid nothing beyond the quote it met: at least half filled at the best bid or ask. The mean slippage was 0.16 basis points, sells 0.17 and buys 0.14, and one trade in twenty paid 0.81 or more, about $8.40 a bitcoin. Some of that is walking the book, and some is the quote moving between its last update and the trade.

Each bar's depth at 5, 10, 20 and 25 levels is in ƒL2 Order Book Liquidity, its imbalance at each depth in ƒL2 Order Book Imbalance, and how far each trade filled from the quote in ƒSlippage.

Binance BTC-USDT perpetual, the five-minute bar from 14:00 UTC on 14 May 2025, from Aperiodic's free sample. Depth and imbalance are the book at the end of the bar; slippage covers every trade in it. Sizes in bitcoin.

What you learned

Level
One price in the book, with everything waiting there added up.
Walking the book
An order bigger than the best level takes the next level, then the next, each at a worse price.
Slippage
How far an order's average price lands from the best quote it met, in basis points: over the best ask for a buy, under the best bid for a sell.
Depth
How much waits on the first 5, 10, 20 or 25 levels of a side. The thinner the book, the further an order walks.
Book imbalance
Bids minus asks over the same levels, divided by their sum: positive when more waits to buy. Near and far levels can lean opposite ways.

Check yourself

  1. 1. The best ask holds 10 units. You buy 8. What is your slippage?

  2. 2. Halve what waits at every level. What happens to the slippage of the same order?

  3. 3. On the first five levels, 60 units wait to buy and 40 to sell. What is the book imbalance?

Lesson 5 of 10.

Next

Lesson 6: Every trade leaves a mark

After a big order, how much of the move stays?

Read lesson 6All lessons

Your progress stays in this browser. A free account keeps it on any device and lets you pull the data behind these lessons yourself: every metric for 2025 on BTC, ETH, SOL and 10 RWA perps, on an API key of your own. Get the data

Read every lesson on one page

11 min left
  1. Walking the book
  2. Past the best ask
  3. Thin and thick
  4. Which side is heavier
  5. In real data
  6. What you learned
  7. Check yourself
Aperiodic

Built from hundreds of terabytes of raw data and distilled into point-in-time metrics you can pull as parquet files. Plus the raw trades, quotes and derivatives data behind them.

Use Cases
  • Improve your backtest
  • Find new alpha
  • Execute smarter
Indices
  • All indices
  • Aperiodic Cost Index
  • Aperiodic Depth Index
  • Aperiodic Impact Index
Metrics
  • Metrics library
  • Data Catalog
  • Free data
  • Live markets dashboard
  • Every perp, A–Z
  • Global Liquidity
  • Unusual activity
  • Order Flow
  • L1 & L2
  • Derivatives
  • RWA
  • Live funding rates
  • Raw Data
Developers
  • Docs
  • API Docs
  • MCP Server
  • Notebooks
  • Integrations
  • For AI Agents
  • Atlas Security Master
  • TParquet
  • Binance OI history API
  • OKX history APIs
  • Pre-flight
  • Changelog
  • Roadmap
  • llms.txt
Learn
  • Markets from First Principles
  • Replays
  • Microstructure Guide
  • Architecture
  • Research Blog
  • FAQ
Compare
  • All vendors
  • Pricing compared
  • vs. Tardis
  • vs. CoinGlass
  • vs. Kaiko
  • vs. Amberdata
  • vs. Crypto Lake
  • vs. Laevitas
  • vs. Coinalyze
  • vs. Binance public data
  • vs. Hyperliquid data
  • Binance archive
  • Hyperliquid data
Company
  • Team
  • Pricing
  • Contact
  • Book a call
  • Terms of Service
  • Privacy Policy
  • Licensing
  • SLA

© Copyright 2026 Aperiodic. All Rights Reserved.

Aperiodic Limited · Registered in Ireland · Company No. 815273 ·
136 Capel Street, Dublin D01 T2C9, Ireland