get_vol_surface
Fetch an options underlying's implied volatility surface as a grid of expiries and strikes, with implied vol, delta, and option prices, enabling deterministic local repricing and risk analysis.
Instructions
IB's implied volatility surface for an underlying: a grid of (expiry, strike) with impliedVol, delta, optPrice, undPrice and daysToExpiry.
This is the input that makes local repricing deterministic. With IB's own volatilities in hand, a constant-volatility scenario needs no proprietary model — only Black-76 arithmetic on top of numbers IB published.
Do not collapse the surface to one number. Volatility has a term structure: ES at 139 days can sit near 15% at the money while the front month prints 12%. Using the front month for a longer tenor understates a long-dated position badly. Read the tenor you need, and interpolate between tenors in total variance if you must.
daysToExpiry counts to the settlement date. For AM-settled expiries
that is one day past the last trading date TWS shows.
Strikes with no published volatility come back under missing with the
reason rather than being silently absent — a surface missing its left wing
looks identical to one that has none.
Check which instrument you got. A bare root is ambiguous: ES is the
E-mini S&P 500 future and Eversource Energy on NYSE, and with no
sec_type the stock wins. The resolved contract comes back under
underlying, any collision is listed in warnings, and a surface on the
wrong instrument looks perfectly reasonable until you notice the strikes
are two orders of magnitude off.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rights | No | Puts by default; pass both for the full smile. | |
| strikes | No | Explicit strikes. Each is snapped to the nearest listed one. | |
| expiries | Yes | Expiries as YYYYMMDD or YYYY-MM-DD. Either the last trading date or the settlement date works; both resolve to the same contracts. | |
| sec_type | No | Which instrument the symbol means. Left empty the search tries STK, then IND, then FUT — so 'ES' returns Eversource Energy, not the E-mini S&P. Pass FUT for a futures root. Any collision is reported in `warnings` either way. | |
| max_strike | No | ||
| min_strike | No | ||
| underlying | Yes | Underlying root, e.g. 'ES' or 'SPY'. | |
| trading_class | No | Needed when one underlying has two contracts expiring the same day, e.g. 'ES' (quarterly, AM-settled) against 'EW4' (weekly, PM-settled). | |
| max_strikes_per_expiry | No | Cap per expiry. Each strike is one market data line and IB allows about fifty at once, so a wide grid over many expiries takes time. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||