Options Payoff Curve Skill
Generates a fully interactive HTML widget (via visualize:show_widget) showing:
- - Expiry payoff curve (dashed gray line) — intrinsic value at expiration
- Theoretical value curve (solid colored line) — Black-Scholes price at current DTE/IV
- Dynamic sliders for all key parameters
- Real-time stats: max profit, max loss, breakevens, current P&L at spot
Step 1: Extract Strategy From User Input
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. For SPX, check market data — as of March 2026 SPX ≈ 5,500. Never default spot to a strike price value.
Step 2: Identify Strategy Type
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 |
|
naked_put | Sell Put K | Single leg |
|
ratio_spread | Buy 1×K1, Sell N×K2 | Unequal quantities |
For strategies not listed, use custom mode: decompose into individual legs and sum their P&Ls.
Step 3: Compute Payoffs
Black-Scholes Put Price
CODEBLOCK0
Black-Scholes Call Price (via put-call parity)
CODEBLOCK1
Butterfly Put Payoff (expiry)
if S >= K3: 0
if S >= K2: K3 - S
if S >= K1: S - K1
else: 0
Net P&L per share = payoff − premium_paid
Vertical Spread (call debit) Payoff (expiry)
CODEBLOCK3
Calendar Spread Theoretical Value
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.
Iron Condor Payoff (expiry)
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
Step 4: Render the Widget
Use visualize:read_me with modules ["chart", "interactive"] before building.
Required Controls (sliders)
Structure section:
- - All strike prices (K1, K2, K3... as needed by strategy)
- Premium paid/received
- Quantity
- Multiplier (100 default, show for clarity)
Pricing variables section:
- - IV % (5–80%, step 0.5)
- DTE — days to expiry (0–90)
- Risk-free rate % (0–8%)
Spot price:
- - Full-width slider, range = [minstrike - 20%, maxstrike + 20%], defaulting to ACTUAL current spot
Required Stats Cards (live-updating)
- - Max profit (expiry)
- Max loss (expiry)
- Breakeven(s) — show both for two-sided strategies
- Current theoretical P&L at spot
Chart Specs
- - X-axis: SPX/underlying price
- Y-axis: Total USD P&L (not per-share)
- Blue solid line = theoretical value at current DTE/IV
- Gray dashed line = expiry payoff
- Green dashed vertical = strike prices (K2 center strike brighter)
- Amber dashed vertical = current spot price
- Fill above zero = green 10% opacity; below zero = red 10% opacity
- Tooltip: show both curves on hover
Code template
Use this JS structure inside the widget, adapting pnlExpiry() and bfTheory() per strategy:
CODEBLOCK6
Step 5: Respond to User
After rendering the widget, briefly explain:
- 1. What strategy was detected and how legs were mapped
- Max profit / max loss at current settings
- One key insight (e.g., "spot is currently 950 pts below the profit zone, expiring tomorrow")
Keep it concise — the chart speaks for itself.
Reference Files
- -
references/strategies.md — Detailed payoff formulas and edge cases for each strategy type - INLINECODE8 — Copy-paste ready Black-Scholes JS implementation with normCDF
Read the relevant reference file if you're unsure about payoff formula edge cases for a given strategy.
期权收益曲线技能
生成一个完全交互式的HTML小部件(通过visualize:show_widget),展示:
- - 到期收益曲线(灰色虚线)——到期时的内在价值
- 理论价值曲线(彩色实线)——当前到期天数/隐含波动率下的布莱克-舒尔斯价格
- 所有关键参数的动态滑块
- 实时统计数据:最大利润、最大亏损、盈亏平衡点、当前标的价格下的盈亏
第一步:从用户输入中提取策略信息
当用户提供截图或文本时,提取以下信息:
| 字段 | 查找位置 | 缺失时的默认值 |
|---|
| 策略类型 | 标题栏/腿描述 | custom |
| 标的资产 |
股票代码 | SPX |
| 行权价 | 标题或腿表格中的K1、K2、K3... | 最近的整数 |
| 权利金支付/收取 | 成交价或均价 | 5.00 |
| 数量 | 持仓规模 | 1 |
| 乘数 | 股票期权为100,SPX为100 | 100 |
| 到期日 | 标题中的日期 | 30天到期 |
| 标的价格 | 当前标的资产价格(非行权价) | 中间行权价 |
| 隐含波动率 | 希腊值面板中显示,或根据维加估算 | 20% |
| 无风险利率 | — | 4.3% |
截图关键提示:标的价格是指标的指数/股票的当前价格,而非行权价。对于SPX,请查看市场数据——截至2026年3月,SPX≈5,500。切勿将标的价格默认设置为行权价。
第二步:识别策略类型
匹配到以下支持的策略之一,然后阅读references/strategies.md中的相应部分。
| 策略 | 腿 | 关键标识 |
|---|
| 蝶式 | 买入K1,卖出2×K2,买入K3 | 3个行权价,标题含Butterfly |
| 垂直价差 |
买入K1,卖出K2(相同到期日) | 2个行权价,借方或贷方 |
|
日历价差 | 买入远月K,卖出近月K | 相同行权价,2个到期日 |
|
铁秃鹰 | 卖出K2/K3,买入K1/K4保护翼 | 4个行权价,2个价差 |
|
跨式 | 买入看涨K + 买入看跌K | 相同行权价,两种类型 |
|
宽跨式 | 买入虚值看涨 + 买入虚值看跌 | 2个行权价,均为虚值 |
|
备兑开仓 | 做多100股 + 卖出看涨K | 股票 + 卖出看涨 |
|
裸卖看跌 | 卖出看跌K | 单腿 |
|
比率价差 | 买入1×K1,卖出N×K2 | 数量不等 |
对于未列出的策略,使用custom模式:分解为单个腿并汇总其盈亏。
第三步:计算收益
布莱克-舒尔斯看跌期权价格
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
每股净盈亏 = 收益 − 已付权利金
垂直价差(看涨借方)到期收益
long_call = max(S - K1, 0)
short_call = max(S - K2, 0)
payoff = longcall - shortcall - net_debit
日历价差理论价值
日历价差无法用简单的到期函数表示——始终对两条腿使用BS定价:
value = BS(S, K, Tfar, r, IVfar) - BS(S, K, Tnear, r, IVnear)
日历价差的到期曲线:近月腿到期无价值,远月腿 = 剩余时间的BS价格。
铁秃鹰到期收益
put_spread = max(K2-S, 0) - max(K1-S, 0) // 卖出看跌价差
call_spread = max(S-K3, 0) - max(S-K4, 0) // 卖出看涨价差
payoff = creditreceived - putspread - call_spread
第四步:渲染小部件
在构建之前,使用visualize:read_me并加载模块[chart, interactive]。
必需控件(滑块)
结构部分:
- - 所有行权价(K1、K2、K3...根据策略需要)
- 已付/已收权利金
- 数量
- 乘数(默认100,为清晰起见显示)
定价变量部分:
- - 隐含波动率%(5–80%,步长0.5)
- 到期天数(0–90)
- 无风险利率%(0–8%)
标的价格:
- - 全宽滑块,范围 = [最小行权价 - 20%, 最大行权价 + 20%],默认为实际当前标的价格
必需统计卡片(实时更新)
- - 最大利润(到期)
- 最大亏损(到期)
- 盈亏平衡点——双向策略显示两个
- 当前标的价格下的理论盈亏
图表规格
- - X轴:SPX/标的资产价格
- Y轴:总美元盈亏(非每股)
- 蓝色实线 = 当前到期天数/隐含波动率下的理论价值
- 灰色虚线 = 到期收益
- 绿色垂直虚线 = 行权价(K2中间行权价更亮)
- 琥珀色垂直虚线 = 当前标的价格
- 零线上方填充 = 绿色10%透明度;零线下方填充 = 红色10%透明度
- 工具提示:悬停时显示两条曲线
代码模板
在小部件内使用此JS结构,根据策略调整pnlExpiry()和bfTheory():
js
// 布莱克-舒尔斯辅助函数(始终包含)
function normCDF(x) { / 霍纳近似 / }
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();
第五步:回应用户
渲染小部件后,简要说明:
- 1. 检测到何种策略以及如何映射各腿
- 当前设置下的最大利润/最大亏损
- 一个关键见解(例如:标的价格目前低于盈利区域950点,明天到期)
保持简洁——图表本身会说明一切。
参考文件
- - references/strategies.md — 每种策略类型的详细收益公式和边界情况
- references/bs_code.md — 包含normCDF的即用型布莱克-舒尔斯JS实现
如果对给定策略的收益公式边界情况不确定,请阅读相关参考文件。