volatility
它能做什么
这项技能测试一种押注波动率会回归其正常水平的策略。适合研究平静与动荡市场如何交替出现的交易者。
适用场景
- ✓当你认为一段平静的低波动期之后可能出现更大的变动的时候。
- ✓当某只股票的波动率处于异常高位,而你想测试一条退出规则的时候。
- ✓当你想比较加密货币或股票价格数据中的波动率状态的时候。
技能链接
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/volatility/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在这只股票上测试一个波动率策略:当波动率处于其历史的最低 20% 时买入。”
每周 5 个新技能,1 分钟读完。
工作原理
它会在滚动窗口上计算历史波动率,并将其与近期历史进行排名比较。当波动率较低时做多,当波动率较高时平仓或做空,在两者之间则保持当前仓位。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Volatility Strategy
Purpose
Uses percentile ranking of historical volatility (HV) to capture volatility mean reversion: build positions in low-volatility regimes while waiting for volatility expansion, and exit or short in high-volatility regimes to capture contraction.
Signal Logic
- Compute HV: annualized standard deviation of returns over the past
hv_windowdays - Percentile ranking: percentile position of HV within the past
lookbackdays (0-100) - Signal generation:
- Percentile <
low_pct→ go long (volatility is low, waiting for expansion) - Percentile >
high_pct→ exit / go short (volatility is high, waiting for contraction) - Middle region → keep the current position
- Percentile <
Key Implementation Details
- HV =
returns.rolling(hv_window).std() * sqrt(252)(annualized) - Percentile =
hv.rolling(lookback).rank(pct=True) * 100 - For cryptocurrencies, use 365 instead of 252 as the annualization factor
Parameters
| Parameter | Default | Description |
|---|---|---|
| hv_window | 20 | Historical volatility calculation window |
| lookback | 120 | Lookback period for percentile ranking |
| low_pct | 20.0 | Low-volatility threshold (percentile) |
| high_pct | 80.0 | High-volatility threshold (percentile) |
| annualize | 252 | Annualization factor (252 for China A-shares, 365 for crypto) |
Common Pitfalls
- Before the lookback window is filled, there is not enough data to compute percentiles, so the signal should be 0 (
fillna) - Volatility is not direction. Going long in low-volatility regimes does not guarantee price appreciation; it only means volatility expansion is statistically more likely
- Cryptocurrencies trade 7x24, so
annualizeshould be set to 365
Dependencies
pip install pandas numpy
Signal Convention
1= long (low-volatility regime),-1= short (high-volatility regime),0= stand aside
常见问题
什么是历史波动率?
它是近期收益率的年化标准差,衡量价格近来变动的幅度。
为什么加密货币使用 365?
加密货币每天都在交易,因此技能在年化波动率时使用 365,而不是 252。
这个策略总是有效的吗?
不一定。波动率倾向于回归,但没有保证,因此应先进行测试。
详情
作者的原始描述
Volatility strategy. Trades mean reversion based on percentile ranking of historical volatility (HV). Suitable for any OHLCV data.
repo: HKUDS/Vibe-Trading
热度
- GitHub 星标
- 37k
- 排名
- #7566
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …