IVMixin#
Calculates Black-Scholes implied volatility for a given price using a root-finding algorithm.
This implementation uses Brent's method for speed and precision, with a fallback to a more robust Secant method if the initial search fails.
Source code in src/quantfin/techniques/base/iv_mixin.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
implied_volatility(option: Option, stock: Stock, model: BaseModel, rate: Rate, target_price: float, low: float = 1e-06, high: float = 5.0, tol: float = 1e-06, **kwargs: Any) -> float
#
Calculates the implied volatility for a given option price.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
option
|
Option
|
The option contract. |
required |
stock
|
Stock
|
The underlying asset's properties. |
required |
model
|
BaseModel
|
The model to use for pricing. Note: IV is always calculated relative to the Black-Scholes-Merton model. |
required |
rate
|
Rate
|
The risk-free rate structure. |
required |
target_price
|
float
|
The market price of the option for which to find the IV. |
required |
low
|
float
|
The lower bound for the volatility search, by default 1e-6. |
1e-06
|
high
|
float
|
The upper bound for the volatility search, by default 5.0. |
5.0
|
tol
|
float
|
The tolerance for the root-finding algorithm, by default 1e-6. |
1e-06
|
Returns:
Type | Description |
---|---|
float
|
The implied volatility, or |