options-payoff
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOptions Payoff Curve Skill
期权收益曲线Skill
Generates a fully interactive HTML widget (via ) showing:
visualize:show_widget- 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
生成可通过调用的全交互式HTML组件,展示内容包括:
visualize:show_widget- 到期收益曲线(灰色虚线)——到期时的内在价值
- 理论价值曲线(彩色实线)——当前DTE/IV下的Black-Scholes定价
- 所有关键参数的动态滑块
- 实时统计数据:最大盈利、最大亏损、盈亏平衡点、当前现货价格下的盈亏
Step 1: Extract Strategy From User Input
步骤1:从用户输入中提取策略
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.
当用户提供截图或文本时,提取以下信息:
| 字段 | 查找位置 | 缺失时默认值 |
|---|---|---|
| 策略类型 | 标题栏/期权腿描述 | "custom" |
| 标的资产 | 交易代码 | SPX |
| 执行价格 | 标题或期权腿表格中的K1、K2、K3... | 最近的整数 |
| 支付/收取的权利金 | 成交价格或平均价格 | 5.00 |
| 数量 | 持仓规模 | 1 |
| 乘数 | 股票期权为100,SPX期权为100 | 100 |
| 到期日 | 标题中的日期 | 30 DTE |
| 现货价格 | 标的资产当前价格(非执行价格) | 中间执行价格 |
| IV | 希腊字母面板中显示的值,或通过Vega估算 | 20% |
| 无风险利率 | — | 4.3% |
截图处理关键注意事项:现货价格是标的指数/股票的当前价格,而非执行价格。对于SPX,请参考市场数据——截至2026年3月,SPX≈5500。切勿将现货价格默认设置为执行价格。
Step 2: Identify Strategy Type
步骤2:识别策略类型
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 mode: decompose into individual legs and sum their P&Ls.
custom将用户输入匹配到以下支持的策略之一,然后查阅中的对应章节。
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 | 数量不等 |
对于未列出的策略,使用模式:将其分解为单个期权腿,然后累加各腿的盈亏。
customStep 3: Compute Payoffs
步骤3:计算收益
Black-Scholes Put Price
Black-Scholes看跌期权定价
d1 = (ln(S/K) + (r + σ²/2)·T) / (σ·√T)
d2 = d1 - σ·√T
put = K·e^(-rT)·N(-d2) - S·N(-d1)d1 = (ln(S/K) + (r + σ²/2)·T) / (σ·√T)
d2 = d1 - σ·√T
put = K·e^(-rT)·N(-d2) - S·N(-d1)Black-Scholes Call Price (via put-call parity)
Black-Scholes看涨期权定价(通过期权平价公式)
call = put + S - K·e^(-rT)call = put + S - K·e^(-rT)Butterfly Put Payoff (expiry)
蝶式看跌期权到期收益
if S >= K3: 0
if S >= K2: K3 - S
if S >= K1: S - K1
else: 0Net P&L per share = payoff − premium_paid
if S >= K3: 0
if S >= K2: K3 - S
if S >= K1: S - K1
else: 0每股净盈亏 = 收益 − 支付的权利金
Vertical Spread (call debit) Payoff (expiry)
垂直价差(看涨期权借方)到期收益
long_call = max(S - K1, 0)
short_call = max(S - K2, 0)
payoff = long_call - short_call - net_debitlong_call = max(S - K1, 0)
short_call = max(S - K2, 0)
payoff = long_call - short_call - 净借方金额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.
日历价差无法用简单的到期函数表示——始终对两个期权腿使用Black-Scholes定价:
value = BS(S, K, T_far, r, IV_far) - BS(S, K, T_near, r, IV_near)日历价差的到期曲线:近期期权腿到期作废,远期期权腿 = 剩余期限T下的Black-Scholes定价。
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_spreadput_spread = max(K2-S, 0) - max(K1-S, 0) // 看跌期权空头价差
call_spread = max(S-K3, 0) - max(S-K4, 0) // 看涨期权空头价差
payoff = 收取的权利金 - put_spread - call_spreadStep 4: Render the Widget
步骤4:渲染组件
Use with modules before building.
visualize:read_me["chart", "interactive"]在构建前,使用并加载模块。
visualize:read_me["chart", "interactive"]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 = [min_strike - 20%, max_strike + 20%], defaulting to ACTUAL current spot
结构参数区:
- 所有执行价格(K1、K2、K3...根据策略需求)
- 支付/收取的权利金
- 数量
- 乘数(默认100,显示以明确说明)
定价变量区:
- IV %(5–80%,步长0.5)
- DTE——到期天数(0–90)
- 无风险利率 %(0–8%)
现货价格:
- 全宽滑块,范围 = [最小执行价格 - 20%, 最大执行价格 + 20%],默认值为实际当前现货价格
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
- X轴:SPX/标的资产价格
- Y轴:总美元盈亏(非每股)
- 蓝色实线 = 当前DTE/IV下的理论价值
- 灰色虚线 = 到期收益
- 绿色虚线垂直线 = 执行价格(中间执行价格K2更亮)
- 黄色虚线垂直线 = 当前现货价格
- 零轴上方填充 = 10%透明度绿色;零轴下方填充 = 10%透明度红色
- 提示框:hover时显示两条曲线的数据
Code template
代码模板
Use this JS structure inside the widget, adapting and per strategy:
pnlExpiry()bfTheory()js
// 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();在组件中使用以下JS结构,根据策略调整和:
pnlExpiry()bfTheory()js
// Black-Scholes辅助函数(必须包含)
function normCDF(x) { /* Horner近似法 */ }
function bsCall(S,K,T,r,sig) { /* 标准Black-Scholes看涨期权定价 */ }
function bsPut(S,K,T,r,sig) { /* 标准Black-Scholes看跌期权定价 */ }
// 策略专属到期收益(返回每股未扣除权利金的收益)
function expiryValue(S, ...strikes) { ... }
// 策略专属理论价值(使用Black-Scholes计算)
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();Step 5: Respond to User
步骤5:回复用户
After rendering the widget, briefly explain:
- 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.
渲染组件后,简要说明:
- 检测到的策略类型,以及期权腿的映射方式
- 当前设置下的最大盈利/最大亏损
- 一个关键洞察(例如:“当前现货价格比盈利区间低950点,明日到期”)
保持简洁——图表已能直观展示信息。
Reference Files
参考文件
- — Detailed payoff formulas and edge cases for each strategy type
references/strategies.md - — Copy-paste ready Black-Scholes JS implementation with normCDF
references/bs_code.md
Read the relevant reference file if you're unsure about payoff formula edge cases for a given strategy.
- — 各策略类型的详细收益公式和边缘情况说明
references/strategies.md - — 可直接复制使用的Black-Scholes JS实现,包含normCDF函数
references/bs_code.md
若对特定策略的收益公式边缘情况有疑问,请查阅相关参考文件。