跳到正文
Skillpedia
分析与电子表格37k · #7539

options-strategy

它能做什么

这项技能在过去的价格数据上测试期权交易策略。适合希望看到多腿期权组合过去表现如何的交易者和研究人员。

适用场景

  • ✓当你想在过去的价格上测试备兑看涨或保护性看跌策略的时候。
  • ✓当你在比较鹰式、蝶式或日历价差等思路的时候。
  • ✓当你需要查看期权策略整个存续期内的 Greeks 风险敞口的时候。

技能链接

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

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/options-strategy/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请在这份加密货币价格历史上回测备兑看涨策略,并展示结果。”

每周 5 个新技能,1 分钟读完。

工作原理

它使用 Black-Scholes 模型,根据标的价格估算期权价格。然后它会随时间模拟每个仓位的盈亏、Greeks 以及到期行权的情况。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Purpose

Backtesting of option portfolio strategies. Starting from the underlying price, the engine synthesizes theoretical option prices with the Black-Scholes model, then simulates PnL, Greeks exposure, and expiration exercise for multi-leg option portfolios.

Applicable scenarios:

  • Hedging strategies (covered call, protective put)
  • Volatility trading (straddle, strangle)
  • Spread strategies (iron condor, butterfly, calendar spread)
  • Option pricing analysis and Greeks sensitivity research

Supported Strategy Types

Strategy Structure Applicable Market View
Covered Call Hold underlying + short call Mildly bullish, collect premium
Protective Put Hold underlying + long put Bullish but wants downside protection
Straddle Buy same-strike call + put Expect large movement, direction uncertain
Strangle Buy different-strike call + put Expect large movement, lower cost
Iron Condor Sell put spread + sell call spread Range-bound market, collect premium
Butterfly Buy low call + sell 2 middle calls + buy high call Expect narrow-range movement
Calendar Spread Sell near-month + buy far-month at same strike Exploit differences in time decay

OptionsSignalEngine Interface

Write the strategy in code/signal_engine.py, with class name SignalEngine, implementing the generate method:

class SignalEngine:
    """Option strategy signal engine."""

    def generate(self, data_map: dict) -> list:
        """Generate option trading instructions.

        Args:
            data_map: code -> DataFrame (columns: open, high, low, close, volume)

        Returns:
            List of trading instructions. Each instruction has the format:
            {
                "date": "2024-01-15",        # Trading date
                "action": "open" / "close",  # Open or close position
                "underlying": "BTC-USDT",    # Underlying code
                "legs": [                    # List of option legs
                    {
                        "type": "call" / "put",  # Option type
                        "strike": 50000,          # Strike price
                        "expiry": "2024-02-15",   # Expiration date
                        "qty": 1                  # Quantity (positive = long, negative = short)
                    }
                ]
            }
        """

Multi-Leg Combination Example

Iron Condor opening signal:

{
    "date": "2024-01-15",
    "action": "open",
    "underlying": "000300.SH",
    "legs": [
        {"type": "put",  "strike": 3800, "expiry": "2024-02-15", "qty": -1},  # Sell put
        {"type": "put",  "strike": 3700, "expiry": "2024-02-15", "qty":  1},  # Buy protective put
        {"type": "call", "strike": 4200, "expiry": "2024-02-15", "qty": -1},  # Sell call
        {"type": "call", "strike": 4300, "expiry": "2024-02-15", "qty":  1},  # Buy protective call
    ]
}

Ready-made engines for covered call, cash-secured put, iron condor, vol-gated short strangle and protective put live in example_signal_engine.py next to this file.

config.json Format

{
    "codes": ["000300.SH"],
    "start_date": "2020-01-01",
    "end_date": "2024-12-31",
    "source": "tushare",
    "engine": "options",
    "initial_cash": 1000000,
    "commission": 0.001,
    "options_config": {
        "risk_free_rate": 0.05,
        "iv_source": "historical",
        "contract_multiplier": 1.0,
        "same_day_fill": false,
        "default_iv": 0.3
    }
}

Key fields:

  • engine must be set to "options" so the runner selects the option backtest engine
  • options_config.risk_free_rate: risk-free rate, default 0.05
  • options_config.iv_source: volatility source, currently supports "historical" (30-day rolling historical volatility computed from underlying closes)
  • options_config.contract_multiplier: contract multiplier, default 1.0
  • options_config.same_day_fill: false (default) fills a signal dated T on the next bar's close; true restores the legacy same-date fill (signal and fill share T's close and IV)
  • options_config.default_iv: volatility used for bars without a full rolling window (warm-up and NaN gaps), default 0.3; must be finite and positive

BS Model Principles

Black-Scholes formula (European options):

Call = S * N(d1) - K * e^(-rT) * N(d2)
Put  = K * e^(-rT) * N(-d2) - S * N(-d1)

d1 = [ln(S/K) + (r + sigma^2/2) * 
常见问题

它需要真实的期权价格吗?

不需要。它根据标的价格,通过 Black-Scholes 构建理论价格。

它适用于哪些市场?

该技能称它适用于加密货币期权和股票期权。

什么是鹰式策略?

它是一种区间策略,通过卖出一个看跌价差和一个看涨价差来收取权利金。

详情

作者的原始描述

Options strategy framework supporting Black-Scholes pricing, Greeks analysis, and multi-leg backtesting. Suitable for cryptocurrency and equity options.

repo: HKUDS/Vibe-Trading

热度

GitHub 星标
37k
排名
#7539
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能