Security Options Strategy
/install security-options-strategy
\r \r
Options Strategy Master / 期权策略大师\r
\r
English: AI-powered options strategy master — covers options pricing, Greeks calculation, multi-leg strategies, and volatility trading. Built for options traders and risk managers.\r \r 中文: 期权策略大师——覆盖期权定价、Greeks计算、多腿策略分析、波动率交易。适用:期权交易者、风险管理人。\r \r ---\r \r
Industry Pain Points / 行业痛点\r
\r | Pain Point / 痛点 | Impact / 影响 | Solution / 本Skill解决方案 |\r |------------------|-------------|------------------------|\r | 定价复杂 | BS模型参数选择困难 | 参数解释+敏感性分析 |\r | 希腊字母难懂 | Delta/Gamma/Vega傻傻分不清 | 可视化Greeks图形 |\r | 策略选择困难 | 不知道用什么策略应对市场 | 情景化策略推荐 |\r | 保证金占用 | 资金效率低 | 最优保证金管理 |\r | 风险敞口不清晰 | 极端行情爆仓 | 实时风险监控+预警 |\r \r ---\r \r
Trigger Keywords / 触发关键词\r
\r English Triggers: options strategy, options pricing, Greeks, volatility trading, China options, covered call, protective put, spread trading, straddles, collars\r \r 中文触发词(优先): 期权策略 / 期权定价 / 希腊字母 / Delta / Gamma / Vega / 备兑开仓 / 保护性看跌 / 价差策略 / 跨式策略 / 勒式策略 / 波动率交易 / 50ETF期权 / 沪深300期权 / 期权开户 / 期权权限 / 权利仓 / 义务仓 / 做市商 / 波动率曲面\r \r ---\r \r
Core Capabilities / 核心能力\r
\r
1. Options Pricing Engine / 期权定价引擎\r
\r
import numpy as np\r
from scipy.stats import norm\r
\r
class OptionsPricer:\r
"""期权定价引擎"""\r
\r
@staticmethod\r
def black_scholes(S, K, T, r, sigma, option_type='call'):\r
"""\r
Black-Scholes期权定价\r
Args:\r
S: 标的资产价格\r
K: 行权价\r
T: 到期时间(年)\r
r: 无风险利率\r
sigma: 波动率\r
option_type: 'call' 或 'put'\r
"""\r
if T \x3C= 0:\r
if option_type == 'call':\r
return max(S - K, 0)\r
else:\r
return max(K - S, 0)\r
\r
d1 = (np.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))\r
d2 = d1 - sigma * np.sqrt(T)\r
\r
if option_type == 'call':\r
price = S * norm.cdf(d1) - K * np.exp(-r * T) * norm.cdf(d2)\r
delta = norm.cdf(d1)\r
else:\r
price = K * np.exp(-r * T) * norm.cdf(-d2) - S * norm.cdf(-d1)\r
delta = norm.cdf(d1) - 1\r
\r
# Greeks计算\r
gamma = norm.pdf(d1) / (S * sigma * np.sqrt(T))\r
vega = S * norm.pdf(d1) * np.sqrt(T) / 100 # 每1%波动率变化\r
theta_call = (-S * norm.pdf(d1) * sigma / (2 * np.sqrt(T)) - \r
r * K * np.exp(-r * T) * norm.cdf(d2)) / 365\r
theta_put = (-S * norm.pdf(d1) * sigma / (2 * np.sqrt(T)) + \r
r * K * np.exp(-r * T) * norm.cdf(-d2)) / 365\r
\r
return {\r
'price': round(price, 4),\r
'delta': round(delta, 4),\r
'gamma': round(gamma, 6),\r
'vega': round(vega, 4),\r
'theta': round(theta_call if option_type == 'call' else theta_put, 4),\r
'd1': round(d1, 4),\r
'd2': round(d2, 4)\r
}\r
\r
@staticmethod\r
def implied_volatility(market_price, S, K, T, r, option_type='call'):\r
"""计算隐含波动率(牛顿迭代法)"""\r
sigma = 0.3 # 初始猜测\r
\r
for _ in range(100):\r
bs_price = OptionsPricer.black_scholes(S, K, T, r, sigma, option_type)['price']\r
vega = OptionsPricer.black_scholes(S, K, T, r, sigma, option_type)['vega'] * 100\r
\r
diff = market_price - bs_price\r
\r
if abs(diff) \x3C 1e-6:\r
break\r
\r
sigma = sigma + diff / vega\r
\r
if sigma \x3C 0.01 or sigma > 5:\r
return None\r
\r
return round(sigma * 100, 2) # 返回百分比\r
```\r
\r
### 2. Options Strategy Analysis / 期权策略分析\r
\r
```python\r
class OptionsStrategy:\r
"""期权策略分析"""\r
\r
STRATEGIES = {\r
"covered_call": {\r
"name": "备兑开仓",\r
"description": "持有标的+卖出看涨期权",\r
"use_case": "预期横盘/小幅上涨,想增加收益",\r
"max_profit": "股价 - 行权价 + 权利金",\r
"max_loss": "无限(理论上)"\r
},\r
"protective_put": {\r
"name": "保护性看跌",\r
"description": "持有标的+买入看跌期权",\r
"use_case": "担心下跌,想锁定损失",\r
"max_profit": "无限",\r
"max_loss": "行权价 - 股价 + 权利金"\r
},\r
"bull_call_spread": {\r
"name": "牛市看涨价差",\r
"description": "买入低行权价看涨+卖出高行权价看涨",\r
"use_case": "看涨但涨幅有限",\r
"max_profit": "行权价差 - 净权利金",\r
"max_loss": "净权利金"\r
},\r
"bear_put_spread": {\r
"name": "熊市看跌价差",\r
"description": "买入高行权价看跌+卖出低行权价看跌",\r
"use_case": "看跌但跌幅有限",\r
"max_profit": "行权价差 - 净权利金",\r
"max_loss": "净权利金"\r
},\r
"straddle": {\r
"name": "跨式策略",\r
"description": "同时买入同行权价的看涨+看跌",\r
"use_case": "预期大幅波动但方向不明",\r
"max_profit": "无限(上涨)或标的 - 行权价(下跌)",\r
"max_loss": "两倍权利金"\r
},\r
"strangle": {\r
"name": "勒式策略",\r
"description": "买入高行权价看涨+低行权价看跌",\r
"use_case": "预期大幅波动但方向不明(成本低于跨式)",\r
"max_profit": "无限",\r
"max_loss": "两倍权利金"\r
},\r
"iron_condor": {\r
"name": "铁鹰策略",\r
"description": "卖出价差+买入更宽价差保护",\r
"use_case": "预期标的在一定范围内波动",\r
"max_profit": "净权利金",\r
"max_loss": "两个价差幅度 - 净权利金"\r
}\r
}\r
\r
def analyze_strategy(self, strategy_name: str, \r
underlying_price: float,\r
params: dict) -> dict:\r
"""分析策略损益"""\r
if strategy_name not in self.STRATEGIES:\r
return {"error": "未知策略"}\r
\r
strategy = self.STRATEGIES[strategy_name]\r
analysis = {\r
"strategy": strategy["name"],\r
"description": strategy["description"],\r
"use_case": strategy["use_case"]\r
}\r
\r
# 计算不同标的价格下的盈亏\r
price_range = np.linspace(\r
underlying_price * 0.7,\r
underlying_price * 1.3,\r
100\r
)\r
\r
pnl_curve = self._calculate_pnl(strategy_name, price_range, params)\r
\r
# 关键指标\r
breakeven = self._find_breakeven(pnl_curve, price_range)\r
max_profit = self._find_max_profit(pnl_curve, price_range)\r
max_loss = self._find_max_loss(pnl_curve, price_range)\r
\r
return {\r
**analysis,\r
"breakeven": round(breakeven, 2),\r
"max_profit": round(max_profit, 2),\r
"max_loss": round(max_loss, 2),\r
"profit_table": {\r
"大幅下跌(-20%)": round(self._pnl_at_price(strategy_name, \r
underlying_price * 0.8, params), 2),\r
"小幅下跌(-10%)": round(self._pnl_at_price(strategy_name, \r
underlying_price * 0.9, params), 2),\r
"横盘(0%)": round(self._pnl_at_price(strategy_name, \r
underlying_price, params), 2),\r
"小幅上涨(+10%)": round(self._pnl_at_price(strategy_name, \r
underlying_price * 1.1, params), 2),\r
"大幅上涨(+20%)": round(self._pnl_at_price(strategy_name, \r
underlying_price * 1.2, params), 2)\r
}\r
}\r
```\r
\r
### 3. Volatility Trading / 波动率交易\r
\r
```markdown\r
## 波动率交易框架\r
\r
### 波动率微笑/曲面分析\r
```python\r
def analyze_volatility_smile(option_chain: dict) -> dict:\r
"""\r
分析波动率微笑曲面\r
识别相对高估/低估期权\r
"""\r
# 计算各行权价的隐含波动率\r
iv_curve = {\r
strike: calculate_iv(option_price, spot, strike, days_to_expiry, r)\r
for strike, option_price in option_chain.items()\r
}\r
\r
# 波动率偏斜分析\r
atm_iv = iv_curve[get_atm_strike(spot)]\r
skew = {\r
otm_put_10: atm_iv - iv_curve[otm_put_10],\r
otm_call_10: iv_curve[otm_call_10] - atm_iv\r
}\r
\r
return {\r
"iv_curve": iv_curve,\r
"atm_volatility": atm_iv,\r
"skew": skew,\r
"opportunity": "IV高估卖出" if skew > threshold else "IV低估买入"\r
}\r
```\r
```\r
\r
---\r
\r
## Quick Command Templates / 快速指令模板\r
\r
**期权定价:**\r
```\r
计算50ETF期权定价:\r
- 标的价格:2.8元\r
- 行权价:2.85元\r
- 到期日:30天后\r
- 波动率:20%\r
- 类型:看涨期权\r
```\r
\r
**分析策略:**\r
```\r
分析牛市看涨价差策略:\r
- 买入行权价:3.0元,权利金:0.05元\r
- 卖出行权价:3.2元,权利金:0.02元\r
- 标的现价:2.9元\r
```\r
\r
---\r
\r
## Disclaimer\r
\r
Options trading involves substantial risk and is not suitable for all investors. Losses can exceed initial investment. This skill is for educational purposes only and does not constitute investment advice.\r
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install security-options-strategy - After installation, invoke the skill by name or use
/security-options-strategy - Provide required inputs per the skill's parameter spec and get structured output
What is Security Options Strategy?
AI-powered options strategy tool for China market with options pricing, Greeks, multi-leg strategies (covered call, protective put, spreads, straddles), and... It is an AI Agent Skill for Claude Code / OpenClaw, with 50 downloads so far.
How do I install Security Options Strategy?
Run "/install security-options-strategy" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Security Options Strategy free?
Yes, Security Options Strategy is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Security Options Strategy support?
Security Options Strategy is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Security Options Strategy?
It is built and maintained by lingfeng-19 (@gechengling); the current version is v2.0.0.