OU Processes#

These are the classes that implement gaussian and non-gaussian Ornstein-Uhlenbeck process.

class quantflow.sp.ou.Vasicek(*, rate: ~typing.Annotated[float, ~annotated_types.Gt(gt=0)] = 1.0, kappa: ~typing.Annotated[float, ~annotated_types.Gt(gt=0)] = 1.0, bdlp: ~quantflow.sp.weiner.WeinerProcess = <factory>, theta: ~typing.Annotated[float, ~annotated_types.Gt(gt=0)] = 1.0)#

Gaussian OU process, also know as the Vasiceck model.

Historically, the Vasicek model was used to model the short rate, but it can be used to model any process that reverts to a mean level at a rate proportional to the difference between the current level and the mean level.

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

It derives from IntensityProcess, although, it is not strictly an intensity process since it is not positive.

Methods:

analytical_cdf

Analytical cdf of the process at time t

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

The log-Laplace transform of the cumulative process:

sample

Generate random Paths from the process.

sample_from_draws

Sample Paths from the process given a set of draws

Attributes:

bdlp

Background driving Weiner process

model_config

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

theta

Mean rate \(\theta\)

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

Analytical cdf of the process at time t

Implement if available

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

Implement if available

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: ndarray[tuple[int, ...], dtype[floating[Any]]] | float, 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: ndarray[tuple[int, ...], dtype[floating[Any]]] | float, u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

The log-Laplace transform of the cumulative process:

\[e^{\phi_{t, u}} = {\mathbb E} \left[e^{i u \int_0^t x_s ds}\right]\]
Parameters:
  • t – time horizon

  • u – frequency

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

Sample Paths from the process given a set of draws

bdlp: WeinerProcess#

Background driving Weiner process

kappa: float#

Mean reversion speed \(\kappa\)

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

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

rate: float#

Instantaneous initial rate \(r_0\)

theta: float#

Mean rate \(\theta\)

class quantflow.sp.ou.GammaOU(*, rate: Annotated[float, Gt(gt=0)] = 1.0, kappa: Annotated[float, Gt(gt=0)] = 1.0, bdlp: CompoundPoissonProcess[Exponential])#

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

cumulative_characteristic2

Formula from a paper

integrated_log_laplace

The log-Laplace transform of the cumulative process:

sample

Generate random Paths from 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

Implement if available

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: ndarray[tuple[int, ...], dtype[floating[Any]]] | float, u: int | float | complex | ndarray | Series) int | float | complex | ndarray | Series#

Characteristic exponent at time t for a given input parameter

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

Formula from a paper

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

The log-Laplace transform of the cumulative process:

\[e^{\phi_{t, u}} = {\mathbb E} \left[e^{i u \int_0^t x_s ds}\right]\]
Parameters:
  • t – time horizon

  • u – frequency

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

kappa: float#

Mean reversion speed \(\kappa\)

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

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

rate: float#

Instantaneous initial rate \(r_0\)