Sub topic 5
The Bid-Ask Spread
This chapter assumes you can read a basic order book (best bid, best ask, size at each price), that you know 1 basis point (bp) is 0.01%, and that you can follow short Python snippets. Maker and taker orders were covered earlier. Slippage, which comes from walking deeper into the book, gets its own chapter.
What the spread is
The bid is the highest price a buyer is currently willing to pay. The ask is the lowest price a seller is currently willing to accept. The bid-ask spread is the gap between them:
- Absolute spread = best ask − best bid
- Mid price = (best bid + best ask) / 2
- Relative spread in bp = absolute spread / mid × 10,000
Quote the spread in basis points, not in currency units. A spread of 0.20 means very different things on a 100.00 asset and on a 0.50 asset. In basis points you can compare any two markets directly.
def spread_stats(best_bid, best_ask):
if best_bid <= 0 or best_ask <= 0:
raise ValueError("prices must be positive")
if best_ask < best_bid:
raise ValueError("crossed book: stale or inconsistent data")
mid = (best_bid + best_ask) / 2
absolute = best_ask - best_bid
return mid, absolute, absolute / mid * 10_000
mid, absolute, bps = spread_stats(99.8, 100.0)
print(round(mid, 2), round(absolute, 2), round(bps, 1)) # 99.9 0.2 20.0The check for a crossed book matters in practice. A healthy book never has a bid above the ask, because the matching engine would trade those orders against each other. If your data shows a crossed book, you are looking at stale or mismatched snapshots, such as a bid from one message and an ask from another.
Why the spread is a cost
If you buy at the ask and immediately sell at the bid, you lose the spread even though the market did not move. Measured against the mid price, each market order costs about half the spread. A taker pays half the spread on entry and half on exit.
qty = 10
buy_price, sell_price = 100.0, 99.8 # buy at the ask, sell at the bid
fee_bps = 20 # taker fee on each side, illustrative
buy_cost = qty * buy_price * (1 + fee_bps / 10_000)
sell_proceeds = qty * sell_price * (1 - fee_bps / 10_000)
loss = buy_cost - sell_proceeds
mid_notional = qty * (buy_price + sell_price) / 2
print(round(loss, 3)) # 6.004
print(round(loss / mid_notional * 10_000, 1)) # 60.1 bpsThe 60.1 bp loss is the 20 bp spread plus 20 bp of fees on each side. The price never moved, yet the position is down 0.6%. A trade must move in your favor by this amount before you break even.
Why spreads exist
Market makers post both bids and asks and earn the difference. The spread pays them for three risks:
- Inventory risk. A maker who buys from you now holds an asset whose price may fall before they can sell it.
- Adverse selection. Some takers know something the maker does not, such as news or a large order elsewhere. Makers lose money to these traders and recover it from everyone else through wider spreads.
- Operating cost. Infrastructure, capital tied up in the book, and fees all have to be covered.
This explains why spreads widen exactly when you least want them to: during fast moves, when inventory risk and adverse selection are highest.
What makes a spread wide or narrow
| Factor | Effect on spread | Why |
|---|---|---|
| Trading volume | Higher volume, narrower | More makers compete for flow |
| Volatility | Higher volatility, wider | Inventory risk grows |
| Time of day | Thin hours, wider | Fewer participants quote |
| Asset size | Small-cap tokens, wider | Few makers, higher risk |
| Tick size | Coarse ticks set a floor | The spread cannot be smaller than one tick |
| Venue fees | Higher maker fees, wider | Makers must recover costs |
Tick size is easy to overlook. If the minimum price increment is 0.01 and the asset trades near 100, the tightest possible spread is 1 bp. Heavily traded pairs often sit at exactly one tick, so the spread cannot fall further and the queue of orders at the best price becomes the competition instead.
Edge cases and gotchas
- The displayed spread is only the top of the book. It describes the cost of a small order. A larger market order walks past the best level and pays slippage on top (see the slippage chapter). The spread is the lower bound on what you pay as a taker, not an estimate for any size.
- The spread moves. A snapshot taken at 03:00 UTC says little about 14:30 UTC, when scheduled economic data is released. Check the spread at the time you intend to trade.
- Quotes can be thin. A tight spread with 0.01 units at the best price is not a tight market. Look at the size shown next to each price.
- Different venues, different spreads. The same pair can have a 2 bp spread on one exchange and 15 bp on another. Spread is a property of a specific order book, not of the asset.
- Stablecoin pairs are quoted differently. A pair such as USDT/USD may trade within a fraction of a basis point, so check enough decimal places to see the actual gap.
- Locked books. Some venues briefly show bid equal to ask (a zero spread). This is usually transient and does not mean trading is free, because fees still apply.
Maker orders and the spread
A maker order rests in the book and does not cross the spread. If you place a buy at the bid and it fills, you paid the bid price, not the ask, so you did not pay the half-spread that a taker would. That is why the earlier round-trip function treats a resting order as having no spread cost.
The trade-off is certainty. A resting order may never fill, or it may fill only when the price is moving against you. Orders at the best bid tend to fill when sellers are aggressive, which is often when the price is about to drop. This is the adverse selection that makers charge for, now paid by you. Saving 10 bp of half-spread is not a gain if the unfilled order forces you to chase the price later.
def round_trip_cost_bps(spread_bps, fee_bps_each_side, slippage_bps_each_side=0.0):
return spread_bps + 2 * fee_bps_each_side + 2 * slippage_bps_each_side
print(round_trip_cost_bps(spread_bps=2, fee_bps_each_side=20)) # taker: 42 bps
print(round_trip_cost_bps(spread_bps=0, fee_bps_each_side=10)) # maker: 20 bpsWith a 2 bp spread the taker pays 42 bp in total, and 40 of those are fees. For liquid pairs the fee often dominates the spread. For illiquid pairs the relationship reverses, and a 100 bp spread makes fees look small.
The spread is not the only hidden margin
Instant-buy and convert screens do not show an order book. They show one price, and the spread, or something larger, is built into it. The next chapters cover how to extract that markup by comparing the quoted price with the mid price on a venue's order book.
Exercises
Exercise
A book shows best bid 2,499.00 and best ask 2,501.00. What is the mid price and the relative spread in basis points? What is the cost of a taker round trip with a 10 bp taker fee on each side, ignoring slippage?
Show answer
Mid = (2,499 + 2,501) / 2 = 2,500.00. Absolute spread = 2.00. Relative spread = 2 / 2,500 × 10,000 = 8 bp. Round trip = 8 + 2 × 10 = 28 bp.
Exercise
A trader places a resting buy at the best bid to avoid paying the spread, but the order only fills after the price has already dropped 30 bp. Explain why this fill may cost more than crossing the spread would have, and name the effect.
Show answer
The order filled because sellers were pushing the price down, so the trader bought just before further decline, or at a time when the price was moving against them. This is adverse selection. Saving about half the spread (for example 5 to 10 bp) does not offset a 30 bp adverse move, so the taker order at the start could have been cheaper.