Free lesson · Crypto markets
Order-book depth and average execution price
Open interactive lessonPractice calculationsExplore labs
Start with the idea
The best ask covers only the quantity resting there. Larger orders consume deeper, often more expensive levels.
Symbols, units & horizon
- i: executed price level
- q_i: base units filled at level i
- P_i: quote units per base unit
- P-bar: volume-weighted execution price in quote/base
- one order episode
When and why to use this
Estimate size-dependent execution costs for spot and cross-venue research.
The best ask covers only the quantity resting there. Larger orders consume deeper, often more expensive levels.
Walk the visible asks until the desired base quantity is filled. Multiply each fill price by its quantity and divide total quote cost by filled base units.
Visible depth is a snapshot, not a promise. Cancellations, hidden liquidity, latency and fees change actual fills. Keep unfilled quantity explicit; do not divide cost by the requested quantity when fewer units fill.
Order-book depth and average execution price
- Calculate quote cost q_iP_i at every filled level.
- Sum actual filled quantities and costs.
- Divide total cost by actual filled quantity and report unfilled units separately.
Buy .5 BTC at 50,000 and .3 BTC at 50,100. Cost=25,000+15,030=40,030 quote units; average=40,030/.8=50,037.50.
Apply it in a strategy
- Estimate size-dependent execution costs for spot and cross-venue research.
- Record the input timestamp, executable quantity, currency and horizon. Reconcile the result with a cash-flow or state table.
- Stress this failure condition: Static depth assumes the book survives until arrival and ignores competing orders.
Research deliverable
Build and explain a order-book depth and average execution price worksheet. Estimate size-dependent execution costs for spot and cross-venue research.
Evidence boundary: Synthetic arithmetic and scenarios illustrate mechanics. They are not historical returns, a paper replication, or evidence of an executable edge. Research sources and their access limitations are recorded at the end of this module.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
# Python 3.10+; standard library unless NumPy is imported below.
# Inputs and outputs use the units defined in this lesson. Synthetic teaching example.
def execution_average(fills):
if not fills or any(q<=0 or p<=0 for q,p in fills): raise ValueError("Positive quantity/price fills required")
quantity=sum(q for q,p in fills)
cost=sum(q*p for q,p in fills)
return quantity,cost,cost/quantity
print(execution_average([(.5,50000),(.3,50100)]))Continue learning
Crypto Markets: Instruments, Ownership and Cash Flows — all lessons- Base, quote and instrument identity
- Returns across two currencies
- Order-book depth and average execution price
- Stablecoin conversion is an FX route
- Custody claims and recovery scenarios
- Token issuance, unlocks and dilution
- Staking rewards and economic return
- A reconciled spot research ledger
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations