Vectorized Integration IV Solver#
A high-performance, vectorized Secant method solver for implied volatility for any model that supports a characteristic function.
Source code in src/quantfin/calibration/vectorized_integration_iv.py
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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
__init__(max_iter: int = 20, tolerance: float = 1e-07, upper_bound: float = 200.0)
#
Initializes the vectorized IV solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_iter
|
int
|
Maximum number of iterations for the Secant method, by default 20. |
20
|
tolerance
|
float
|
Error tolerance for convergence, by default 1e-7. |
1e-07
|
upper_bound
|
float
|
The upper limit for the numerical integration, by default 200.0. |
200.0
|
Source code in src/quantfin/calibration/vectorized_integration_iv.py
solve(target_prices: np.ndarray, options: pd.DataFrame, model: BaseModel, rate: Rate) -> np.ndarray
#
Calculates implied volatility for an array of options and prices.
This method uses a vectorized Secant root-finding algorithm. The pricing at each step is performed using a vectorized version of the Gil-Pelaez inversion formula.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_prices
|
ndarray
|
An array of market prices for which to find the implied volatility. |
required |
options
|
DataFrame
|
A DataFrame of option contracts. |
required |
model
|
BaseModel
|
The financial model to use for pricing. |
required |
rate
|
Rate
|
The risk-free rate structure. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
An array of calculated implied volatilities. |