options-payoff

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Options Payoff Curve Skill

期权收益曲线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

生成可通过
visualize:show_widget
调用的全交互式HTML组件,展示内容包括:
  • 到期收益曲线(灰色虚线)——到期时的内在价值
  • 理论价值曲线(彩色实线)——当前DTE/IV下的Black-Scholes定价
  • 所有关键参数的动态滑块
  • 实时统计数据:最大盈利、最大亏损、盈亏平衡点、当前现货价格下的盈亏

Step 1: Extract Strategy From User Input

步骤1:从用户输入中提取策略

When the user provides a screenshot or text, extract:
FieldWhere to find itDefault if missing
Strategy typeTitle bar / leg description"custom"
UnderlyingTicker symbolSPX
Strike(s)K1, K2, K3... in title or leg tablenearest round number
Premium paid/receivedFilled price or avg price5.00
QuantityPosition size1
Multiplier100 for equity options, 100 for SPX100
ExpiryDate in title30 DTE
Spot priceCurrent underlying price (NOT strike)middle strike
IVShown in greeks panel, or estimate from vega20%
Risk-free rate4.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期权为100100
到期日标题中的日期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
.
StrategyLegsKey Identifiers
butterflyBuy K1, Sell 2×K2, Buy K33 strikes, "Butterfly" in title
vertical_spreadBuy K1, Sell K2 (same expiry)2 strikes, debit or credit
calendar_spreadBuy far-expiry K, Sell near-expiry KSame strike, 2 expiries
iron_condorSell K2/K3, Buy K1/K4 wings4 strikes, 2 spreads
straddleBuy Call K + Buy Put KSame strike, both types
strangleBuy OTM Call + Buy OTM Put2 strikes, both OTM
covered_callLong 100 shares + Sell Call KStock + short call
naked_putSell Put KSingle leg
ratio_spreadBuy 1×K1, Sell N×K2Unequal quantities
For strategies not listed, use
custom
mode: decompose into individual legs and sum their P&Ls.

将用户输入匹配到以下支持的策略之一,然后查阅
references/strategies.md
中的对应章节。
策略期权腿关键识别特征
蝶式期权(butterfly)买入K1,卖出2×K2,买入K33个执行价格,标题中包含“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
模式:将其分解为单个期权腿,然后累加各腿的盈亏。

Step 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: 0
Net 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_debit
long_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_spread

put_spread = max(K2-S, 0) - max(K1-S, 0)   // 看跌期权空头价差
call_spread = max(S-K3, 0) - max(S-K4, 0)  // 看涨期权空头价差
payoff = 收取的权利金 - put_spread - call_spread

Step 4: Render the Widget

步骤4:渲染组件

Use
visualize:read_me
with modules
["chart", "interactive"]
before building.
在构建前,使用
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
pnlExpiry()
and
bfTheory()
per strategy:
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:
  1. What strategy was detected and how legs were mapped
  2. Max profit / max loss at current settings
  3. One key insight (e.g., "spot is currently 950 pts below the profit zone, expiring tomorrow")
Keep it concise — the chart speaks for itself.

渲染组件后,简要说明:
  1. 检测到的策略类型,以及期权腿的映射方式
  2. 当前设置下的最大盈利/最大亏损
  3. 一个关键洞察(例如:“当前现货价格比盈利区间低950点,明日到期”)
保持简洁——图表已能直观展示信息。

Reference Files

参考文件

  • references/strategies.md
    — Detailed payoff formulas and edge cases for each strategy type
  • references/bs_code.md
    — 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.
  • references/strategies.md
    — 各策略类型的详细收益公式和边缘情况说明
  • references/bs_code.md
    — 可直接复制使用的Black-Scholes JS实现,包含normCDF函数
若对特定策略的收益公式边缘情况有疑问,请查阅相关参考文件。