Calibrator#
A generic class for calibrating financial models to market data.
This class orchestrates the process of finding the model parameters that minimize the difference between model prices and observed market prices.
Source code in src/quantfin/calibration/calibrator.py
17 18 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 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 144 145 146 147 148 149 150 151 152 153 154 155 |
|
__init__(model: BaseModel, market_data: pd.DataFrame, stock: Stock, rate: Rate)
#
Initializes the Calibrator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
BaseModel
|
The financial model to be calibrated (e.g., HestonModel). |
required |
market_data
|
DataFrame
|
A DataFrame containing market prices of options. Must include 'strike', 'maturity', 'optionType', and 'marketPrice' columns. |
required |
stock
|
Stock
|
The underlying asset's properties. |
required |
rate
|
Rate
|
The risk-free rate structure. |
required |
Source code in src/quantfin/calibration/calibrator.py
fit(initial_guess: dict[str, float], bounds: dict[str, tuple], frozen_params: dict[str, float] = None) -> dict[str, float]
#
Performs the calibration using an optimization algorithm.
This method uses scipy.optimize.minimize
(or minimize_scalar
for
a single parameter) to find the optimal set of parameters that
minimizes the objective function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial_guess
|
dict[str, float]
|
A dictionary of initial guesses for the parameters to be fitted. |
required |
bounds
|
dict[str, tuple]
|
A dictionary mapping parameter names to their (min, max) bounds. |
required |
frozen_params
|
dict[str, float] | None
|
A dictionary of parameters to hold constant during the optimization. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
dict[str, float]
|
A dictionary containing the full set of calibrated and frozen parameters. |