CIR#

The Cox–Ingersoll–Ross (CIR) model

class quantflow.sp.cir.CIR(*, rate: Annotated[float, Gt(gt=0)] = 1.0, kappa: Annotated[float, Gt(gt=0)] = 1.0, sigma: Annotated[float, Gt(gt=0)] = 1.0, theta: Annotated[float, Gt(gt=0)] = 1.0, sample_algo: SamplingAlgorithm = SamplingAlgorithm.implicit)#

The Cox–Ingersoll–Ross (CIR) model is a mean-reverting square-root diffusion process.

The process \(x_t\) that satisfies the following stochastic differential equation with Wiener process \(w_t\):

\[dx_t = \kappa (\theta - x_t) dt + \sigma \sqrt{x_t}dw_t\]

This process is guaranteed to be positive if

\[2 \kappa \theta >= \sigma^2\]
Parameters:
  • rate – The initial value of the process \(x_0\)

  • kappa – Mean reversion speed \(\kappa\)

  • sigma – Volatility parameter \(\sigma\)

  • theta – Long term mean rate \(\theta\)

Methods:

analytical_mean

Analytical mean of the process at time t

analytical_pdf

Analytical pdf of the process at time t

analytical_variance

Analytical variance of the process at time t

characteristic_exponent

Characteristic exponent at time t for a given input parameter

integrated_log_laplace

Integrated log Laplace transform of the process

sample

Generate random Paths from the process.

sample_from_draws

Sample Paths from the process given a set of draws

sample_implicit

Use an implicit scheme to preserve positivity of the process.

Attributes:

model_config

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

analytical_mean(t: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float#

Analytical mean of the process at time t

This has a closed form solution.

analytical_pdf(t: ndarray[tuple[int, ...], dtype[floating[Any]]] | float, x: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float#

Analytical pdf of the process at time t

Implement if available

analytical_variance(t: ndarray[tuple[int, ...], dtype[floating[Any]]] | float) ndarray[tuple[int, ...], dtype[floating[Any]]] | float#

Analytical variance of the process at time t

Implement if available

characteristic_exponent(t: int | float | complex | ndarray | Series, u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

Characteristic exponent at time t for a given input parameter

integrated_log_laplace(t: int | float | complex | ndarray | Series, u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

Integrated log Laplace transform of the process

This is the log of the Laplace transform of the process integrated over time.

sample(paths: 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(paths: Paths, *args: Paths) Paths#

Sample Paths from the process given a set of draws

sample_implicit(draws: Paths) Paths#

Use an implicit scheme to preserve positivity of the process.

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

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