execution-model
Skill này làm gì
Skill này thêm chi phí giao dịch thực tế vào backtest, như trượt giá, tác động giá và độ trễ. Skill dành cho trader muốn kết quả mô phỏng gần với những gì xảy ra trên thị trường thật.
Khi nào nên dùng
- ✓Khi một backtest trông quá đẹp và bạn nghi ngờ nó bỏ qua chi phí giao dịch.
- ✓Khi bạn muốn mô phỏng cách một lệnh lớn sẽ làm giá dịch chuyển.
- ✓Khi bạn muốn backtest phản ánh độ trễ giữa tín hiệu và lệnh khớp.
Liên kết skill
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/execution-model/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Chạy lại backtest này với trượt giá thực tế và độ trễ thực hiện một nến, rồi cho tôi xem kết quả thay đổi thế nào.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent dùng các hàm hỗ trợ đã được kiểm chứng để thêm chi phí trượt giá cố định, ước tính tác động thị trường hoặc độ trễ cho mỗi giao dịch mô phỏng. Sau đó nó chạy lại backtest để bạn so sánh kết quả trước và sau. Điều này chỉ áp dụng cho backtest mô phỏng, không dành cho giao dịch thực.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Skill có đặt lệnh thật không?
Không. Nó chỉ thay đổi các giả định trong backtest và không đặt lệnh thật.
Tác động thị trường là gì?
Là mức giá dịch chuyển do một lệnh lớn, thường tăng theo quy mô giao dịch.
Tại sao thêm độ trễ thực thi?
Tín hiệu không thể khớp đúng lúc nó xuất hiện, nên độ trễ làm mô phỏng trung thực hơn.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 37k
- Vị trí xếp hạng
- #7518
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
vibe-trading
37kCho agent của bạn bộ công cụ nghiên cứu tài chính đầy đủ: backtest, phân tích nhân tố, định giá quyền chọn và dữ liệu thị trường nhiều nước.
adr-hshare
37kChỉ cho agent của bạn cách so sánh giá của một công ty Trung Quốc được niêm yết ở nhiều thị trường, như ADR ở Mỹ và cổ phiếu ở Hồng Kông.
akshare
37kCho agent của bạn lấy dữ liệu thị trường miễn phí: cổ phiếu Trung Quốc và toàn cầu, tương lai, ngoại hối, chỉ số kinh tế, không cần API key.
alpha-zoo
37kCho agent của bạn duyệt thư viện nhân tố cổ phiếu dựng sẵn và kiểm tra cả một nhóm nhân tố dự đoán lợi nhuận tốt đến đâu trên thị trường đã chọn.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.