Free lesson · Execution & microstructure
Measure implementation shortfall
Open interactive lessonPractice calculationsExplore labs
Start with the idea
Execution quality should be evaluated against a price known when the decision was made. Including the unfilled portion prevents a strategy from looking good simply because it avoids filling difficult orders.
Symbols, units & horizon
- IS: implementation shortfall in currency, positive means worse than decision price
- d: +1 buy, −1 sell
- Q: positive desired quantity
- qⱼ: positive filled quantity of fill j
- Pⱼ: fill price
- P₀: decision price
- P_T: end-of-horizon opportunity-cost price
- Fees: currency expenses
- VWAP: volume-weighted average price
- Vⱼ: nonnegative volume at price Pⱼ
- Σⱼ: sum across fills or sampled trades
When and why to use this
Use implementation shortfall to compare routing and urgency choices; use a clearly defined VWAP window when that is the mandate’s benchmark.
Compare the ideal order with the realised outcome
- An ideal buy fills all Q at decision price P₀. Filled quantity qⱼ incurs qⱼ(Pⱼ−P₀). Value the unfilled remainder at Pₜ to account for missed opportunity.
- Sum the two pieces, multiply price differences by d=+1 for buys or −1 for sells and add fees. Divide by QP₀ and multiply by 10,000 for shortfall bp.
Buy 1,000 at reference 50; fill 600 at 50.03, end price 50.10, fee 2 → 18+40+2=$60, or 12 bp.
For a parent order of Q positive units, d is +1 for a buy and −1 for a sell, P₀ is the decision price, fills have quantities q and prices P, and P_T values any unfilled remainder at the end of the evaluation window. Positive shortfall is a cost. The unfilled term measures opportunity cost and can be negative.
Derive a volume-weighted price
- Total transacted notional is and total units are . The single price that reproduces that notional satisfies .
- Divide by positive volume. For an incremental update, add the new price×volume to cumulative notional and new volume to cumulative volume.
100 shares at $10 and 300 at $11 give VWAP=(1000+3300)/400=$10.75.
VWAP weights observed trades by volume; TWAP weights intervals equally. A benchmark is only useful if the window, venues, and eligible prints are specified. Beating VWAP can coexist with poor decision-price performance if the market moved before the execution window began.
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.
def implementation_shortfall(side, desired_quantity, fills, decision_price, end_price, fees):
"""fills is [(positive_quantity, price), ...]. Includes unfilled opportunity cost."""
filled = sum(q for q,p in fills)
if side not in (-1,1) or filled > desired_quantity or any(q<0 for q,p in fills):
raise ValueError("Invalid side or fill quantities")
execution = sum(q*(p-decision_price) for q,p in fills)
opportunity = (desired_quantity-filled)*(end_price-decision_price)
return side*(execution+opportunity)+fees
def vwap(price_volume):
volume = sum(v for p,v in price_volume)
if volume <= 0 or any(v<0 for p,v in price_volume):
raise ValueError("Positive aggregate volume required")
return sum(p*v for p,v in price_volume)/volume
print(implementation_shortfall(1,100,[(60,100.1)],100,100.5,2))Continue learning
Execution & Market Microstructure — all lessons- The spread is a price for immediacy
- Measure implementation shortfall
- Capacity is where alpha meets market impact
- Make the order lifecycle auditable
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations