Sub topic 16
Computing the Total Cost of a Trade
This chapter assumes you already know how order books, maker and taker orders, the bid-ask spread, and network fees work. It also assumes you are comfortable with basis points (1 bp = 0.01%) and can read short Python. Here you combine those pieces into one number you can compare across venues and order types.
The cost stack
Each cost in the earlier chapters is quoted in a different unit. Fees are percentages, spreads are price gaps, and network fees are amounts of the chain's own coin. You can't compare them until you convert them to one unit. This chapter uses basis points of the trade's notional, which is the quote-currency value of the order.
| Component | Quoted as | Scales with trade size? | When you pay it |
|---|---|---|---|
| Trading fee | bps of notional | Yes | Every fill |
| Spread | Price gap, converted to bps of mid | Yes | Once per round trip as a taker |
| Slippage | Average price vs. best quote | Yes, and it grows faster than size | Every market order |
| Instant buy markup | Hidden in the price | Yes | Each convert or instant buy |
| Fiat deposit fee | Flat or percent | Depends on the method | Once |
| Withdrawal or network fee | Flat amount of a coin | No | Once per withdrawal |
The table separates costs that scale with size from costs that don't. Variable costs have a similar bps figure at $100 or $100,000. Fixed costs are a flat amount, so their bps figure falls as the trade grows.
Normalizing to basis points
Use two conversions. For a price gap, divide by the mid price. For a flat amount, divide by the notional.
- Spread in bps = (ask - bid) / mid × 10,000
- Fixed cost in bps = fixed amount / notional × 10,000
Fees are already in bps. Slippage is the difference between your average fill and the best quote, as a fraction of the best quote.
Be consistent about the reference price. Spread is measured against the mid. Slippage measured against the best ask starts after the half-spread you already paid. If you measure slippage against the mid instead, you count the half-spread twice.
The round-trip formula
A taker who buys and later sells pays as follows:
- The full spread once. The buy fills at the ask, which is half a spread above mid. The sell fills at the bid, which is half a spread below mid.
- The taker fee on each side.
- Slippage on each side.
A resting maker order fills at the price you set, so the spread term drops out. The maker also pays the (usually lower) maker fee. This assumes the order fills and the market doesn't move against you while you wait.
Worked example in code
The function below computes the variable cost in bps, the total cost in currency, and the total in bps including fixed costs. It assumes a $5,000 notional, a 2 bps spread, a 5 USD withdrawal fee, and the fee rates from earlier chapters (20 bps taker, 10 bps maker).
def to_bps(amount, notional):
return amount / notional * 10_000
def round_trip_cost(notional, spread_bps, fee_bps_each_side,
slippage_bps_each_side=0.0, fixed_costs=0.0):
variable_bps = spread_bps + 2 * fee_bps_each_side + 2 * slippage_bps_each_side
variable_cost = notional * variable_bps / 10_000
total_cost = variable_cost + fixed_costs
return variable_bps, total_cost, to_bps(total_cost, notional)
scenarios = {
"taker": dict(spread_bps=2, fee_bps_each_side=20,
slippage_bps_each_side=3, fixed_costs=5.0),
"maker": dict(spread_bps=0, fee_bps_each_side=10,
slippage_bps_each_side=0, fixed_costs=5.0),
}
for name, params in scenarios.items():
var_bps, total, total_bps = round_trip_cost(5_000.0, **params)
print(f"{name}: variable {var_bps:.1f} bps, total ${total:.2f}, all-in {total_bps:.1f} bps")It prints:
taker: variable 48.0 bps, total $29.00, all-in 58.0 bps
maker: variable 20.0 bps, total $15.00, all-in 30.0 bpsThe taker route costs $14 more on a $5,000 round trip. Almost all of that gap comes from the fee difference (20 bps on each side) and the spread. The $5 withdrawal is the same for both routes.
Fixed costs punish small trades
A flat withdrawal or network fee has little effect on a large trade and a big effect on a small one. The loop below shows the same $5 fee at three trade sizes.
fixed_fee = 5.0
for notional in (100.0, 1_000.0, 10_000.0):
print(notional, round(fixed_fee / notional * 10_000, 1), "bps")The output is 500.0 bps at $100, 50.0 bps at $1,000, and 5.0 bps at $10,000. At $100, the withdrawal fee costs more than a hundred times the spread. For small amounts, the main decision is how many times you pay a fixed fee, not whether you are a maker or a taker. Batching deposits and withdrawals usually helps more than saving a few bps on a single order.
Instant buy and convert
A convert or instant-buy screen often shows "no trading fee." The cost is then in the price. To measure it, compare the price you actually got with the mid price from the order book at the same moment.
def markup_bps(price_paid, mid_price):
return (price_paid - mid_price) / mid_price * 10_000
print(round(markup_bps(100.60, 100.00), 1)) # 60.0 bpsA 60 bps markup is three times the 20 bps taker fee in the earlier example. Add any explicit service fee on top. For a fair comparison, the convert route has no separate spread or slippage term, because the markup replaces both.
Network and withdrawal costs in the total
On-chain costs are quoted in coins, so convert them first:
- Estimate the fee in the chain's native coin: fee rate × virtual size for Bitcoin, or gas used × gas price for EVM chains.
- Multiply by the coin's price in your quote currency.
- Divide by the notional to get bps.
If you withdraw through an exchange, use the exchange's published withdrawal fee, not the on-chain fee. The two can differ, and the exchange keeps any difference. If you are moving your own funds from a self-custody wallet, use the on-chain estimate. Compare both when choosing a route.
Common mistakes
- Counting the spread twice. Add the full spread once per round trip, not once per side.
- Comparing a one-way cost with a round-trip cost. A 20 bps fee quoted per side is 40 bps for a buy and sell.
- Ignoring where the fee is charged. Some venues take the fee from the asset you receive, so your quantity is slightly smaller. The bps calculation still holds, but your coin balance will not match a naive estimate.
- Using the quoted spread for a large order. The top-of-book spread applies only to the first level. A large order should be walked through the book to measure slippage.
- Treating maker as free of risk. A resting order may not fill, or may fill only when the price is moving against you. The saving is real only on fills you actually want.
Exercises
Exercise
You make a taker round trip on a $2,000 notional. The spread is 4 bps, the taker fee is 15 bps per side, slippage is 2 bps per side, and you pay one $3 withdrawal fee. What is the all-in cost in bps?
Show answer
Variable cost = 4 + 2 × 15 + 2 × 2 = 38 bps, which is $7.60 on $2,000. Adding the $3 fixed fee gives $10.60. All-in = 10.60 / 2,000 × 10,000 = 53 bps.
Exercise
A $5 flat withdrawal fee should add no more than 10 bps. What is the smallest notional that meets that limit, and why does a larger trade help?
Show answer
Solve 5 / N × 10,000 = 10, so N = $5,000. A flat fee does not grow with the trade, so a larger notional spreads it over more value and lowers its bps. Variable costs such as fees and spread stay about the same in bps at any size.