Heston process#

class quantflow.sp.heston.Heston(*, variance_process: ~quantflow.sp.cir.CIR = <factory>, rho: ~typing.Annotated[float, ~annotated_types.Ge(ge=-1), ~annotated_types.Le(le=1)] = 0)#

The Heston stochastic volatility model

The classical square-root stochastic volatility model of Heston (1993) can be regarded as a standard Brownian motion \(x_t\) time changed by a CIR activity rate process.

\[\begin{split}\begin{align} d x_t &= d w^1_t \\ d v_t &= \kappa (\theta - v_t) dt + \nu \sqrt{v_t} dw^2_t \\ \rho dt &= {\tt E}[dw^1 dw^2] \end{align}\end{split}\]

Methods:

characteristic_exponent

The characteristic exponent of the Heston model has a closed form

create

Create an Heston model.

sample

Generate random Paths from the process.

sample_from_draws

Sample Paths from the process given a set of draws

Attributes:

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rho

Correlation between the Brownian motions - provides the leverage effect

variance_process

The variance process is a Cox-Ingersoll-Ross (CIR) process

characteristic_exponent(t: ndarray[tuple[int, ...], dtype[floating[Any]]] | float, u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

The characteristic exponent of the Heston model has a closed form

classmethod create(*, rate: float = 1.0, vol: float = 0.5, kappa: float = 1, sigma: float = 0.8, rho: float = 0, theta: float | None = None) Self#

Create an Heston model.

To understand the parameters lets introduce the following notation:

\[\begin{split}\begin{align} {\tt var} &= {\tt vol}^2 \\ v_0 &= {\tt rate}\cdot{\tt var} \end{align}\end{split}\]
Parameters:
  • rate – define the initial value of the variance process

  • vol – The standard deviation of the price process, normalized by the square root of time, as time tends to infinity (the long term standard deviation)

  • kappa – The mean reversion speed for the variance process

  • sigma – The volatility of the variance process

  • rho – The correlation between the Brownian motions of the variance and price processes

  • theta – The long-term mean of the variance process, if None, it defaults to the variance given by \({\tt var}\)

sample(n: int, time_horizon: float = 1, time_steps: int = 100) Paths#

Generate random Paths from the process.

Parameters:
  • n – number of paths

  • time_horizon – time horizon

  • time_steps – number of time steps to arrive at horizon

sample_from_draws(path1: Paths, *args: Paths) Paths#

Sample Paths from the process given a set of draws

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rho: float#

Correlation between the Brownian motions - provides the leverage effect

variance_process: CIR#

The variance process is a Cox-Ingersoll-Ross (CIR) process

class quantflow.sp.heston.HestonJ(*, variance_process: ~quantflow.sp.cir.CIR = <factory>, rho: ~typing.Annotated[float, ~annotated_types.Ge(ge=-1), ~annotated_types.Le(le=1)] = 0, jumps: ~quantflow.sp.poisson.CompoundPoissonProcess)#

The Heston stochastic volatility model with jumps

The Heston model with jumps is an extension of the classical square-root stochastic volatility model of Heston (1993) with the addition of jump processes. The jumps are modeled as compound Poisson processes

\[\begin{split}d x_t &= d w^1_t + d N_t\\ d v_t &= \kappa (\theta - v_t) dt + \nu \sqrt{v_t} dw^2_t \\ \rho dt &= {\tt E}[dw^1 dw^2]\end{split}\]

Methods:

characteristic_exponent

The characteristic exponent is given by the sum of the exponent of the classic Heston model and the exponent of the jumps

exponential

Create an Heston model with DoubleExponential jumps.

Attributes:

jumps

Jump process driven by a compound Poisson process

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

characteristic_exponent(t: ndarray[tuple[int, ...], dtype[floating[Any]]] | float, u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

The characteristic exponent is given by the sum of the exponent of the classic Heston model and the exponent of the jumps

classmethod exponential(*, rate: float = 1.0, vol: float = 0.5, kappa: float = 1, sigma: float = 0.8, rho: float = 0, theta: float | None = None, jump_intensity: float = 100, jump_fraction: float = 0.1, jump_asymmetry: float = 1) HestonJ[DoubleExponential]#

Create an Heston model with DoubleExponential jumps.

To understand the parameters lets introduce the following notation:

\[\begin{split}\begin{align} {\tt var} &= {\tt vol}^2 \\ {\tt var}_j &= {\tt var} \cdot {\tt jump\_fraction} \\ {\tt var}_d &= {\tt var} - {\tt var}_j \\ v_0 &= {\tt rate}\cdot{\tt var}_d \end{align}\end{split}\]
Parameters:
  • rate – define the initial value of the variance process

  • vol – The standard deviation of the price process, normalized by the square root of time, as time tends to infinity (the long term standard deviation)

  • kappa – The mean reversion speed for the variance process

  • sigma – The volatility of the variance process

  • rho – The correlation between the Brownian motions of the variance and price processes

  • theta – The long-term mean of the variance process, if None, it defaults to the diffusion variance given by \({\tt var}_d\)

  • jump_intensity – The number of jumps per year

  • jump_fraction – The percentage of variance due to jumps

  • jump_asymmetry – The asymmetry of the jump distribution (1 for symmetric)

  • jump_distribution – The distribution of the jumps, either ‘normal’ or ‘double_exponential’ (default)

jumps: CompoundPoissonProcess[D]#

Jump process driven by a compound Poisson process

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rho: float#

Correlation between the Brownian motions - provides the leverage effect

variance_process: CIR#

The variance process is a Cox-Ingersoll-Ross (CIR) process