
Execution Model
Trade execution modeling (backtest only), slippage formulas (linear / square-root...
Install
npx skills add HKUDS/Vibe-Trading --skill execution-model -g -a claude-code -y- Repository
- HKUDS/Vibe-Trading37.4k
- Category
- Engineering
- Updated
- 3d ago
- License
- MIT
- Context cost
- Mediumabout 2,823 tokens
- Runs scripts
- No, instructions only
What it does
Trade execution modeling (backtest only), slippage formulas (linear / square-root impact), VWAP/TWAP execution logic, market-impact cost estimation, and execution-assumption configuration.
Trade Execution Modeling
Overview
Provide more realistic execution assumptions for backtests, including slippage models, market-impact estimation, and execution-algorithm principles. This skill is for backtest simulation only and does not involve live order execution.
Slippage Models
Why Slippage Models Are Needed
Idealized backtest: filled at the close, zero slippage
Real world:
1. The order book has a bid-ask spread
2. Large orders push prices (market impact)
3. Execution is delayed (there is latency from signal to fill)
No slippage model -> overly optimistic backtest -> losses in live trading
Do not retype these models. All four are implemented and tested in
src/quantlib/impact.py; import them. The tested versions validate their inputs, a zero ADV raises instead of dividing by zero, and a negative delay_bars raises
instead of silently introducing look-ahead bias.
from src.quantlib.impact import fixed_slippage, linear_impact, sqrt_impact, delayed_execution
1. Fixed Slippage Model
fixed_slippage(price=100.0, direction=1, bps=5.0) # 100.05 (buy pays up)
fixed_slippage(price=100.0, direction=-1, bps=5.0) # 99.95 (sell receives less)
direction is 1 to buy or -1 to sell, and must be exactly one of those, it
multiplies the impact, so an unchecked 2 would silently double the modelled cost.
bps defaults to DEFAULT_SLIPPAGE_BPS (5.0).
Reference fixed-slippage assumptions by market:
