Implied volatility calculator
calculate_implied_volatilityDerive an option's implied volatility from its price and underlying price, returning greeks for what-if pricing and scenario analysis.
Instructions
Compute an option's implied volatility from a given option price, with IBKR's model.
`contract` must be one option (sec_type OPT or FOP with symbol, expiry, strike and
right, or its con_id; futures options also need their exchange, e.g. CME). Returns
`implied_vol` as a decimal (0.25 = 25%) and the greeks at that volatility (delta,
gamma, vega, theta, dividend present value). Useful for what-if pricing: pass a
hypothetical option or underlying price. Nothing is stored or streamed.
Errors: invalid_request when the contract is not an option or no volatility fits the
prices (e.g. an option price below intrinsic value); not_found or ambiguous_contract
when the option cannot be resolved (get_option_chain lists expiries and strikes);
request_timeout when IBKR does not answer within 4 seconds; ib_api_error if IBKR
refuses (it may want market data permissions for the option and its underlying).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contract | Yes | The instrument. A con_id alone is unambiguous; otherwise give symbol and sec_type, plus expiry, strike and right for options. | |
| option_price | Yes | Option price per share (not multiplied by 100), e.g. 5.20. | |
| underlying_price | Yes | Underlying price to assume, e.g. the stock's current price. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| greeks | Yes | IBKR's full model output at that volatility: delta, gamma, vega, theta... | |
| contract | Yes | The option the calculation ran for. | |
| implied_vol | Yes | Implied volatility, annualized, as a decimal (0.25 = 25%). | |
| option_price | Yes | Option price the volatility was implied from. | |
| underlying_price | Yes | Underlying price the calculation assumed. |