# Execution Model

Trade execution modeling (backtest only), slippage formulas (linear / square-root...

- Repository: https://github.com/HKUDS/Vibe-Trading (37375 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add HKUDS/Vibe-Trading --skill execution-model -g -a claude-code -y`
Codex: `npx skills add HKUDS/Vibe-Trading --skill execution-model -g -a codex -y`
Cursor: `npx skills add HKUDS/Vibe-Trading --skill execution-model -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/Vibe-Trading --skill execution-model -g -a gemini-cli -y`

## Description

Trade execution modeling (backtest only), slippage formulas (linear / square-root impact), VWAP/TWAP execution logic, market-impact cost estimation, and execution-assumption configuration.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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.

```python
from src.quantlib.impact import fixed_slippage, linear_impact, sqrt_impact, delayed_execution
```

### 1. Fixed Slippage Model

```python
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:**

The rest: https://github.com/HKUDS/Vibe-Trading/blob/HEAD/agent/src/skills/execution-model/SKILL.md
