本文へスキップ
Skillpedia
分析とスプレッドシート37k · #7518

execution-model

できること

このスキルは、スリッページ、価格インパクト、遅延などの現実的な取引コストをバックテストに加えます。実際の市場に近いシミュレーション結果がほしいトレーダー向けです。

使う場面

  • ✓バックテストが良すぎるように見え、取引コストを無視していると疑うとき。
  • ✓大きな注文が価格をどう動かすかをモデル化したいとき。
  • ✓シグナルと約定の間の遅れを、バックテストに反映させたいとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/execution-model/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“現実的なスリッページと1バーの約定の遅れを加えて、このバックテストを再実行し、結果がどう変わるかを見せてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、テスト済みの補助関数を使って、各シミュレーションの取引に、固定のスリッページ、市場インパクトの推定、または遅れを加えます。その後、バックテストを再実行し、前後の結果を比べられるようにします。これはシミュレーションのバックテストにのみ適用され、実際の取引は行いません。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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:

Market Instrument Suggested Slippage (bps) Notes
China A-share large cap CSI 300 constituents 3-5 Good liquidity
China A-share small cap CSI 1000 constituents 5-10 Average liquidity
China micro-cap market cap < 5 billion RMB 10-30 Poor liquidity
US large cap AAPL / MSFT 1-3 Excellent liquidity
Hong Kong stocks Hang Seng constituents 5-10 Less liquid than A / US
BTC spot BTC-USDT 2-5 Good OKX liquidity
ETH spot ETH-USDT 3-8 Slightly worse than BTC
Small altcoins other -USDT pairs 10-50 Liquidity varies widely

2. Linear Impact Model

impact = impact_coeff × volume_traded / adv

# 100k shares against 1M ADV = 10% participation; at coeff 0.1 that is a 1% move.
linear_impact(price=100.0, direction=1, volume_traded=100_000, adv=1_000_000, impact_coeff=0.1)
# 101.0

Marginal impact is constant here, which overstates the cost of very large orders. impact_coeff defaults to DEFAULT_LINEAR_IMPACT_COEFF (0.1).

Reference impact coefficients:

Market impact_coeff Notes
China A-share large cap 0.05-0.10 10% daily price-limit system
China A-share small cap 0.10-0.20 Liquidity premium
US equities 0.03-0.08 Market-maker buffering
Crypto 0.05-0.15 24h trading is dispersed

3. Square-Root Impact Model

impact = η × σ × sqrt(volume_traded / adv)

# 250k against 1M ADV = 25% participation; 0.5 × 0.02 × sqrt(0.25) = 0.005 = 50bps.
sqrt_impact(price=100.0, direction=1, volume_traded=250_000, adv=1_000_000,
            volatility=0.02, eta=0.5)
# 100.5  (100.49999999999999 in binary floating point)

volatility is daily return volatility as a decimal fraction. eta defaults to DEFAULT_SQRT_IMPACT_ETA (0.5); 0.3-0.8 is the usual calibrated range.

Advantages of the square-root model:

  • Strongest empirical support (standard in financial literature)
  • Marginal impact declines for larger orders (intuitive)
  • Parameters can be estimated from historical data

Naming. This impact term is often labelled "Almgren-Chriss", and it does come from that literature, but it is not Almgren-Chriss optimal execution. There is no trading trajectory, no permanent/temporary impact split and no risk-aversion parameter here, and none is implemented anywhere in this repository. Call it a square-root impact function, and do not claim an optimal schedule was computed.

Slippage Model Selection Decision Tree

Backtest capital vs instrument ADV:
├── Capital < 0.5% of ADV -> fixed slippage (5bps) is enough
├── Capital 0.5-5% -> linear impact model
└── Capital > 5% -> square-root impact model (required)

Execution Algorithm Principles

VWAP (Volume Weighted Average Price)

Goal: execute at the day's volume-weighted average price

VWAP = Σ(Price_i × Volume_i) / Σ(Volume_i)

Execution logic:
1. Forecast the intraday volum
よくある質問

これで実際の取引が行われますか?

いいえ。バックテストの想定を変えるだけで、実際の注文は出しません。

市場インパクトとは何ですか?

大きな注文によって引き起こされる価格の動きで、通常は取引の規模とともに大きくなります。

約定の遅れを加えるのはなぜですか?

シグナルが現れた瞬間に約定できるわけではないため、遅れを入れるとシミュレーションがより正直になるからです。

詳細

作者による元の説明

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

repo: HKUDS/Vibe-Trading

人気

GitHubのスター
37k
ランキング
#7518
ライセンス
MIT
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル