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:

cost_function

Calculate the cost function from the model prices

cost_weight

Calculate the weight for the cost function for a given time to maturity and moneyness

fit

Fit the model

get_bounds

Get the parameter bounds for the calibration

get_constraints

Get the constraints for the calibration

get_params

Get the parameters of the model

implied_vol_range

Get the range of implied volatilities

penalize

Penalize the cost function

plot

Plot the implied volatility for market and model prices

set_params

Set the parameters of the model

Attributes:

minimize_method

The optimization method to use - if None, the default is used

model

Get the model

moneyness_weight

The weight for penalize moneyness as it moves away from 0

options

The options to calibrate

pricer

The OptionPricer for the model

ref_date

Get the reference date

vol_surface

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 the Heston stochastic volatility model

Methods:

get_bounds

Get the parameter bounds for the calibration

get_params

Get the parameters of the model

penalize

Penalize the cost function

set_params

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