Learn / Track VII / lesson 4 of 4
Execution: TWAP, VWAP and implementation shortfall
How large orders are sliced over time, the trade-off between impact and risk, and the Almgren–Chriss answer to it.
A strategy decides what position to hold. An execution algorithm decides how to get there without paying more than necessary in market impact.
The core trade-off
Trade fast and you pay more impact. Trade slowly and you carry more risk that the price moves away before you finish. Every execution algorithm is a choice along that line.
TWAP
Time-weighted average price: split the parent order into equal slices at equal time intervals. To buy over intervals, buy each interval.
Simple, predictable and good when volume is roughly uniform. Its weakness is that it’s predictable — other participants can detect a mechanical pattern — so practical versions randomise slice size and timing.
VWAP
Volume-weighted average price: trade in proportion to the market’s expected volume profile, more when the market is active and less when it’s quiet. For equities, intraday volume is U-shaped (heavy at the open and close); crypto volume follows global session overlaps.
Matching the market’s VWAP is a common benchmark because it is hard to look bad against: you traded like the average participant.
POV
Percentage of volume: participate at a fixed fraction (say 10%) of real-time market volume. It adapts to actual activity but has no fixed finish time.
Implementation shortfall and Almgren–Chriss
The Almgren–Chriss (2000) framework makes the trade-off explicit. With linear temporary impact , volatility and risk aversion , the optimal holding trajectory to liquidate shares over horizon is
- When risk aversion is near zero, and the trajectory becomes a straight line: TWAP.
- When risk aversion is high, is large and the algorithm front-loads trading to cut risk quickly, accepting more impact.
- Rest limit orders first and fall back to marketable orders only when the schedule falls behind.
- Never let a child order exceed a cap relative to visible depth.
- Measure every parent order against its arrival price and log the shortfall. If you don’t measure execution cost, you are almost certainly underestimating it.
- Make every child order idempotent with a client order ID, so retries after timeouts never double-fill. See from spec to live system.
Build this idea
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build an execution service with TWAP and VWAP schedulers, child-order slicing, limit-then-market fallback, idempotent order IDs, and an implementation-shortfall report per parent order- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch