Aperiodic/Markets from First Principles
Markets from First Principles/Part 1, How a price is made

Lesson 1 of 10

From a square to a book

What happens when a crowd wants to trade, and they can't all be there at the same time?

DMBy Daniel and Mark
12 min

Market day

Every trade needs a buyer and a seller whose prices overlap. Each has a limit: the most the buyer will pay, the least the seller will take. When the buyer's limit is at or above the seller's, some price suits them both and they can trade. When it is below, no price does.

Now it's market day. Through the day, 22 people come into the square one at a time, buyers through one gate and sellers through the other, each wanting to buy or sell a sack of grain, each with their limit.

Nobody haggles. In the middle of the square, people who are waiting stand in line with a note saying their price. Whoever arrives reads the notes. If a waiting note suits their limit, they trade with its owner at once, at the price on the note. If none does, they join the line at their own price and wait.

Step 1 of 4

Let people in one at a time. Each one either trades the moment they arrive, or has to wait. Watch who, and at what price.

Nobody here yet. 22 people will come in one at a time, each with the most they'll pay or the least they'll take.

The first seller found nobody and waited at 47. The next person, a buyer who would have paid 60, bought at 47: the price was set by whoever was already waiting. By evening six sacks have changed hands, at prices from 47 to 52, and ten people are still in line.

This is how the markets in this guide trade, around the clock. Orders arrive one at a time, and each one either trades with an order that is already waiting or waits itself. There is no single price for the day: each trade has its own, set by whoever was waiting.

Taking and making

Here are the notes the day left on the board: five to sell and five to buy. Arrive in a hurry and you don't need to wait. Read the board and take the best note: the cheapest sell note if you want to buy, the highest buy note if you want to sell.

Step 2 of 4

How many sacks do you need right now? Pick a number and buy them. Then see what being in a hurry cost you.

Notes to sell
58sell 1
55sell 1
54sell 1
53sell 1sell 1
spread 2 · mid 52
51buy 1
50buy 1buy 1
48buy 1
45buy 1
Notes to buy
3

Nothing bought yet. The ringed notes are the ones you would take: the cheapest first. The mid is 52.

Whoever takes a note is a taker: they pay the price on the board for not having to wait. Everyone who traded on market day was a taker, the moment they arrived. You can also be on the other side, and wait, with a note of your own.

Step 3 of 4

Pin a note to buy one sack at your price, then let the hours pass. See how long you wait, and what you pay compared with buying in a hurry.

Notes to sell
58sell 1
55sell 1
54sell 1
53sell 1sell 1
spread 2 · mid 52
51buy 1
50buy 1buy 1
48buy 1
45buy 1
Notes to buy
51

No note pinned. Pick your price and pin it. Then let the hours pass until someone in a hurry sells to you.

Whoever leaves a note is a maker: they make the board, and they wait for a taker. Notes at the same price are taken in the order they were pinned, so being early counts. Many exchanges charge makers a lower fee than takers (Hyperliquid's fee schedule is one example), because the notes on the board are what let anyone trade at all.

The book

Pin up thousands of notes and the board is too long to read one by one. Add up the notes at each price and you get the order book: the buy notes on one side, called bids, and the sell notes on the other, called asks.

Step 4 of 4

Switch from the notes to the book. The four numbers underneath are what the book tells you.

Notes to sell
58sell 1
55sell 1
54sell 1
53sell 1sell 1
spread 2 · mid 52
51buy 1
50buy 1buy 1
48buy 1
45buy 1
Notes to buy
Live: Ten notes, one card each
Best bid
51
Best ask
53
Spread
2
Mid
52

Switch to the book to see the notes added up at each price.

The highest bid is the best bid, the lowest ask is the best ask, and the gap between them is the spread. The point halfway between is the mid price: one number for where the market stands between trades.

The maths

A buyer with limit L arrives at a book whose best ask is a. A seller with limit L arrives at a best bid b:

buyer: trades at a if a ≤ L, otherwise waits as a bid at L

seller: trades at b if b ≥ L, otherwise waits as an ask at L

For a book with best bid b and best ask a:

spread = a − b, mid = (a + b) / 2, spread in bps = spread / mid × 10,000

In real data

The top of bitcoin's book

SidePriceWaitingIn dollars
best ask103,805.77.712 BTC$800,550
best bid103,805.67.266 BTC$754,251

At the end of the five minutes from 14:00 UTC on 14 May 2025, the best bid on Binance's bitcoin perpetual was 103,805.6 dollars and the best ask 103,805.7. The spread was 10 cents, one tick, and the mid sat halfway between, at 103,805.65.

About $1.55 million was waiting at those two prices. The Depth Index is that number, averaged over the last day, for every perpetual we cover. Each bar's best bid, best ask and mid are in ƒL1 Price, and the dollars waiting in ƒL1 Liquidity.

Binance BTC-USDT perpetual, the five-minute bar from 14:00 UTC on 14 May 2025, from Aperiodic's free sample. Prices in US dollars; each value is the book's state at the end of the bar.

What you learned

Limit
The most a buyer will pay, or the least a seller will take.
Taker
Someone who trades the moment they arrive, with the best note already waiting, at its price.
Maker
Someone who pins a note and waits for a taker, often for a better price.
Order book
Every note still waiting, added up by price: bids to buy on one side, asks to sell on the other.
Best bid, best ask
The highest price anyone will pay, and the lowest anyone will sell at.
Spread and mid
The gap between the best bid and the best ask, and the point halfway between them.

Check yourself

  1. 1. A seller is waiting with a note to sell at 47. A buyer arrives who would pay up to 60. At what price do they trade?

  2. 2. You want a sack right now. Which note do you take?

  3. 3. The best bid is 51 and the best ask is 53. What are the spread and the mid?

Lesson 1 of 10.

Next

Lesson 2: Why there's a gap

Why does buying cost more than selling at the same moment?

Read lesson 2All 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

12 min left
  1. From a square to a book
  2. Market day
  3. Taking and making
  4. The book
  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