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:
Spot for screenshots: spot is the underlying's current price, and broker screenshots often omit it or show it far from the strikes — don't read it off the strike labels. Use the price shown, else a live quote (the SPX probe below, or yfinance for other underlyings). Fall back to the middle strike only when no quote is available, and tell the user you did.
Current SPX reference price:
Step 2: Identify Strategy Type
Match to one of the supported strategies below, then read the corresponding section in references/strategies.md.
For strategies not listed, use custom mode: decompose into individual legs and sum their P&Ls.
Step 3: Compute Payoffs
Black-Scholes Put Price
Black-Scholes Call Price (via put-call parity)
Butterfly Put Payoff (expiry)
Net P&L per share = payoff − premium_paid
Vertical Spread (call debit) Payoff (expiry)
Calendar Spread Theoretical Value
Calendar cannot be expressed as a simple expiry function — always use BS pricing for both legs:
For expiry curve of calendar: near leg expires worthless, far leg = BS with remaining T.
Iron Condor Payoff (expiry)
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 = [min_strike - 20%, max_strike + 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:
Step 5: Respond to User
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.
Reference Files
references/strategies.md— Detailed payoff formulas and edge cases for each strategy typereferences/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.
