options-payoff by himself65/finance-skills
npx skills add https://github.com/himself65/finance-skills --skill options-payoff包含 Shell 命令
此技能包含可能执行系统命令的 shell 命令指令(!command``)。安装前请仔细审查。
生成一个完全交互式的 HTML 小部件(通过 visualize:show_widget)显示:
当用户提供截图或文本时,提取:
| 字段 | 查找位置 | 缺失时的默认值 |
|---|---|---|
| 策略类型 | 标题栏 / 腿描述 | "custom" |
| 标的物 | 股票代码 | SPX |
| 行权价 | 标题或腿表格中的 K1, K2, K3... | 最近的整数 |
| 支付/收取的权利金 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 成交价格或平均价格 |
| 5.00 |
| 数量 | 持仓规模 | 1 |
| 乘数 | 股票期权为 100,SPX 为 100 | 100 |
| 到期日 | 标题中的日期 | 30 DTE |
| 现货价格 | 标的物当前价格(非行权价) | 中间行权价 |
| 隐含波动率 | 希腊字母面板中显示,或根据 vega 估算 | 20% |
| 无风险利率 | — | 4.3% |
截图关键点:现货价格是指数/股票的当前价格,不是行权价。切勿将现货价格默认设置为行权价。
当前 SPX 参考价格:
!`python3 -c "import yfinance as yf; print(f'SPX ≈ {yf.Ticker(\"^GSPC\").fast_info[\"lastPrice\"]:.0f}')" 2>/dev/null || echo "SPX price unavailable — check market data"`
匹配到以下支持策略之一,然后在 references/strategies.md 中阅读相应部分。
| 策略 | 腿数 | 关键标识符 |
|---|---|---|
| butterfly | 买入 K1,卖出 2×K2,买入 K3 | 3 个行权价,标题中有"Butterfly" |
| vertical_spread | 买入 K1,卖出 K2(相同到期日) | 2 个行权价,借方或贷方 |
| calendar_spread | 买入远月 K,卖出近月 K | 相同行权价,2 个到期日 |
| iron_condor | 卖出 K2/K3,买入 K1/K4 翼 | 4 个行权价,2 个价差 |
| straddle | 买入看涨期权 K + 买入看跌期权 K | 相同行权价,两种类型 |
| strangle | 买入虚值看涨期权 + 买入虚值看跌期权 | 2 个行权价,均为虚值 |
| covered_call | 多头 100 股 + 卖出看涨期权 K | 股票 + 空头看涨期权 |
| naked_put | 卖出看跌期权 K | 单腿 |
| ratio_spread | 买入 1×K1,卖出 N×K2 | 数量不等 |
对于未列出的策略,使用 custom 模式:分解为单个腿并求和其 P&L。
d1 = (ln(S/K) + (r + σ²/2)·T) / (σ·√T)
d2 = d1 - σ·√T
put = K·e^(-rT)·N(-d2) - S·N(-d1)
call = put + S - K·e^(-rT)
if S >= K3: 0
if S >= K2: K3 - S
if S >= K1: S - K1
else: 0
每股净 P&L = 盈亏 − 支付的权利金
long_call = max(S - K1, 0)
short_call = max(S - K2, 0)
payoff = long_call - short_call - net_debit
日历价差无法表示为简单的到期函数——始终使用 BS 定价计算两条腿:
value = BS(S, K, T_far, r, IV_far) - BS(S, K, T_near, r, IV_near)
对于日历价差的到期曲线:近月腿到期无价值,远月腿 = 剩余 T 的 BS 价值。
put_spread = max(K2-S, 0) - max(K1-S, 0) // 空头看跌价差
call_spread = max(S-K3, 0) - max(S-K4, 0) // 空头看涨价差
payoff = credit_received - put_spread - call_spread
在构建之前,使用 visualize:read_me 并包含模块 ["chart", "interactive"]。
结构部分:
定价变量部分:
现货价格:
在小部件内部使用此 JS 结构,根据策略调整 pnlExpiry() 和 bfTheory():
// Black-Scholes 辅助函数(始终包含)
function normCDF(x) { /* Horner 近似 */ }
function bsCall(S,K,T,r,sig) { /* 标准 BS 看涨期权 */ }
function bsPut(S,K,T,r,sig) { /* 标准 BS 看跌期权 */ }
// 策略特定的到期盈亏(返回每股价值,在权利金之前)
function expiryValue(S, ...strikes) { ... }
// 策略特定的理论价值,使用 BS
function theoreticalValue(S, ...strikes, T, r, iv) { ... }
// 主 update() 函数读取所有滑块,计算数组,销毁并重新创建 Chart.js 实例
function update() { ... }
// 附加监听器
['k1','k2',...,'iv','dte','rate','spot'].forEach(id => {
document.getElementById(id).addEventListener('input', update);
});
update();
渲染小部件后,简要解释:
保持简洁——图表本身不言自明。
references/strategies.md —— 每种策略类型的详细盈亏公式和边界情况references/bs_code.md —— 可复制粘贴的 Black-Scholes JS 实现,包含 normCDF如果不确定特定策略的盈亏公式边界情况,请阅读相关的参考文件。
每周安装次数
89
仓库
GitHub 星标数
420
首次出现
10 天前
安全审计
安装于
codex84
gemini-cli83
cursor83
kimi-cli82
amp82
cline82
Contains Shell Commands
This skill contains shell command directives (!command``) that may execute system commands. Review carefully before installing.
Generates a fully interactive HTML widget (via visualize:show_widget) showing:
When the user provides a screenshot or text, extract:
| Field | Where to find it | Default if missing |
|---|---|---|
| Strategy type | Title bar / leg description | "custom" |
| Underlying | Ticker symbol | SPX |
| Strike(s) | K1, K2, K3... in title or leg table | nearest round number |
| Premium paid/received | Filled price or avg price | 5.00 |
| Quantity | Position size | 1 |
| Multiplier | 100 for equity options, 100 for SPX | 100 |
| Expiry | Date in title | 30 DTE |
| Spot price | Current underlying price (NOT strike) | middle strike |
| IV | Shown in greeks panel, or estimate from vega | 20% |
| Risk-free rate | — | 4.3% |
Critical for screenshots : The spot price is the CURRENT price of the underlying index/stock, NOT the strikes. Never default spot to a strike price value.
Current SPX reference price:
!`python3 -c "import yfinance as yf; print(f'SPX ≈ {yf.Ticker(\"^GSPC\").fast_info[\"lastPrice\"]:.0f}')" 2>/dev/null || echo "SPX price unavailable — check market data"`
Match to one of the supported strategies below, then read the corresponding section in references/strategies.md.
| Strategy | Legs | Key Identifiers |
|---|---|---|
| butterfly | Buy K1, Sell 2×K2, Buy K3 | 3 strikes, "Butterfly" in title |
| vertical_spread | Buy K1, Sell K2 (same expiry) | 2 strikes, debit or credit |
| calendar_spread | Buy far-expiry K, Sell near-expiry K | Same strike, 2 expiries |
| iron_condor | Sell K2/K3, Buy K1/K4 wings | 4 strikes, 2 spreads |
| straddle | Buy Call K + Buy Put K | Same strike, both types |
| strangle | Buy OTM Call + Buy OTM Put | 2 strikes, both OTM |
| covered_call | Long 100 shares + Sell Call K | Stock + short call |
For strategies not listed, use custom mode: decompose into individual legs and sum their P&Ls.
d1 = (ln(S/K) + (r + σ²/2)·T) / (σ·√T)
d2 = d1 - σ·√T
put = K·e^(-rT)·N(-d2) - S·N(-d1)
call = put + S - K·e^(-rT)
if S >= K3: 0
if S >= K2: K3 - S
if S >= K1: S - K1
else: 0
Net P&L per share = payoff − premium_paid
long_call = max(S - K1, 0)
short_call = max(S - K2, 0)
payoff = long_call - short_call - net_debit
Calendar cannot be expressed as a simple expiry function — always use BS pricing for both legs:
value = BS(S, K, T_far, r, IV_far) - BS(S, K, T_near, r, IV_near)
For expiry curve of calendar: near leg expires worthless, far leg = BS with remaining T.
put_spread = max(K2-S, 0) - max(K1-S, 0) // short put spread
call_spread = max(S-K3, 0) - max(S-K4, 0) // short call spread
payoff = credit_received - put_spread - call_spread
Use visualize:read_me with modules ["chart", "interactive"] before building.
Structure section:
Pricing variables section:
Spot price:
Use this JS structure inside the widget, adapting pnlExpiry() and bfTheory() per strategy:
// Black-Scholes helpers (always include)
function normCDF(x) { /* Horner approximation */ }
function bsCall(S,K,T,r,sig) { /* standard BS call */ }
function bsPut(S,K,T,r,sig) { /* standard BS put */ }
// Strategy-specific expiry payoff (returns per-share value BEFORE premium)
function expiryValue(S, ...strikes) { ... }
// Strategy-specific theoretical value using BS
function theoreticalValue(S, ...strikes, T, r, iv) { ... }
// Main update() reads all sliders, computes arrays, destroys+recreates Chart.js instance
function update() { ... }
// Attach listeners
['k1','k2',...,'iv','dte','rate','spot'].forEach(id => {
document.getElementById(id).addEventListener('input', update);
});
update();
After rendering the widget, briefly explain:
Keep it concise — the chart speaks for itself.
references/strategies.md — Detailed payoff formulas and edge cases for each strategy typereferences/bs_code.md — Copy-paste ready Black-Scholes JS implementation with normCDFRead the relevant reference file if you're unsure about payoff formula edge cases for a given strategy.
Weekly Installs
89
Repository
GitHub Stars
420
First Seen
10 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex84
gemini-cli83
cursor83
kimi-cli82
amp82
cline82
Lark Skill Maker 教程:基于飞书CLI创建AI技能,自动化工作流与API调用指南
39,100 周安装
Remotion视频制作技能:使用React生成高质量宣传片、教程和SNS短视频
132 周安装
阿里云媒体处理服务MPS自动化管理工具 - 支持管道、模板、工作流与任务操作
128 周安装
Swift专家 | iOS/macOS/visionOS原生开发与Swift 6并发性能优化
128 周安装
GitHub Actions CI/CD 流水线模式:自动化构建、测试与部署全指南
129 周安装
Vercel部署与构建指南:自动化构建流水线、预览部署、发布控制与即时回滚
129 周安装
阿里云CDN OpenAPI自动化操作指南 - 域名管理、缓存刷新、HTTPS证书配置
129 周安装
| Sell Put K |
| Single leg |
| ratio_spread | Buy 1×K1, Sell N×K2 | Unequal quantities |