Vol Model Calibration#
- class quantflow.options.calibration.VolModelCalibration(pricer: ~quantflow.options.pricer.OptionPricer[~quantflow.options.calibration.M], vol_surface: ~quantflow.options.surface.VolSurface[~typing.Any], minimize_method: str | None = None, moneyness_weight: float = 0.0, options: dict[~quantflow.options.calibration.ModelCalibrationEntryKey, ~quantflow.options.calibration.OptionEntry] = <factory>)#
Abstract class for calibration of a stochastic volatility model
Methods:
Calculate the cost function from the model prices
Calculate the weight for the cost function for a given time to maturity and moneyness
Fit the model
Get the parameter bounds for the calibration
Get the constraints for the calibration
Get the parameters of the model
Get the range of implied volatilities
Penalize the cost function
Plot the implied volatility for market and model prices
Set the parameters of the model
Attributes:
The optimization method to use - if None, the default is used
Get the model
The weight for penalize moneyness as it moves away from 0
The options to calibrate
The
OptionPricer
for the modelGet the reference date
The
VolSurface
to calibrate the model with- cost_function(params: ndarray) float #
Calculate the cost function from the model prices
- cost_weight(ttm: float, moneyness: float) float #
Calculate the weight for the cost function for a given time to maturity and moneyness
- fit() OptimizeResult #
Fit the model
- get_bounds() Bounds | None #
Get the parameter bounds for the calibration
- get_constraints() Sequence[dict[str, Any]] | None #
Get the constraints for the calibration
- abstract get_params() ndarray #
Get the parameters of the model
Must be implemented by the subclass
- implied_vol_range() Bounds #
Get the range of implied volatilities
- penalize() float #
Penalize the cost function
- plot(index: int = 0, *, max_moneyness_ttm: float | None = 1.0, support: int = 51, **kwargs: Any) Any #
Plot the implied volatility for market and model prices
- abstract set_params(params: ndarray) None #
Set the parameters of the model
Must be implemented by the subclass
- minimize_method: str | None = None#
The optimization method to use - if None, the default is used
- property model: M#
Get the model
- moneyness_weight: float = 0.0#
The weight for penalize moneyness as it moves away from 0
The weight is applied as exp(-moneyness_weight * moneyness), therefore a value of 0 won’t penalize moneyness at all
- options: dict[ModelCalibrationEntryKey, OptionEntry]#
The options to calibrate
- pricer: OptionPricer[M]#
The
OptionPricer
for the model
- property ref_date: datetime#
Get the reference date
- vol_surface: VolSurface[Any]#
The
VolSurface
to calibrate the model with
- class quantflow.options.calibration.HestonCalibration(pricer: ~quantflow.options.pricer.OptionPricer[~quantflow.options.calibration.M], vol_surface: ~quantflow.options.surface.VolSurface[~typing.Any], minimize_method: str | None = None, moneyness_weight: float = 0.0, options: dict[~quantflow.options.calibration.ModelCalibrationEntryKey, ~quantflow.options.calibration.OptionEntry] = <factory>, feller_penalize: float = 0.0)#
A
VolModelCalibration
for theHeston
stochastic volatility modelMethods:
Get the parameter bounds for the calibration
Get the parameters of the model
Penalize the cost function
Set the parameters of the model
- get_bounds() Sequence[Bounds] | None #
Get the parameter bounds for the calibration
- get_params() ndarray #
Get the parameters of the model
Must be implemented by the subclass
- penalize() float #
Penalize the cost function
- set_params(params: ndarray) None #
Set the parameters of the model
Must be implemented by the subclass