OU Processes¶
These are the classes that implement gaussian and non-gaussian Ornstein-Uhlenbeck process.
Gaussian OU process¶
quantflow.sp.ou.Vasicek
pydantic-model
¶
Bases: StochasticProcess1D
Gaussian OU process, also known as the Vasicek 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. Unlike intensity processes, the Vasicek process can take negative values, so it is not constrained to a positive domain.
where \(\kappa\) is the mean reversion speed, \(\theta\) is the mean level, and \(\sigma\) is the volatility of the process. The solution to the SDE is given by
Fields:
-
rate(float) -
kappa(float) -
theta(float) -
bdlp(WienerProcess)
characteristic_exponent
¶
The characteristic exponent of the Vasicek process is given by
Source code in quantflow/sp/ou.py
sample
¶
sample_from_draws
¶
Source code in quantflow/sp/ou.py
ekt
¶
analytical_mean
¶
The analytical mean of the Vasicek process is given by
Source code in quantflow/sp/ou.py
analytical_variance
¶
The analytical variance of the Vasicek process is given by
Source code in quantflow/sp/ou.py
analytical_pdf
¶
analytical_cdf
¶
characteristic
¶
Characteristic function at time t for a given input parameter u
The characteristic function represents the Fourier transform of the probability density function
where \(\phi\) is the characteristic exponent, which can be more easily computed for many processes.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
Time horizon
TYPE:
|
u
|
Characteristic function input parameter
TYPE:
|
Source code in quantflow/sp/base.py
convexity_correction
¶
analytical_std
¶
Analytical standard deviation of the process at time t
This has a closed form solution if the process has an analytical variance
marginal
¶
domain_range
¶
frequency_range
¶
Maximum frequency when calculating characteristic functions
Source code in quantflow/sp/base.py
support
¶
Support of the process at time t
Source code in quantflow/sp/base.py
Non-Gaussian OU process¶
quantflow.sp.ou.NGOU
pydantic-model
¶
Bases: IntensityProcess, Generic[D]
The general definition of a non-Gaussian OU process is defined as the solution to the SDE
where \(Z_{\kappa t}\) is a pure jump Lévy process, also known as the background driving Lévy process (BDLP). The process is mean-reverting with mean reversion speed \(\kappa>0\).
The unusual timing \(dZ_{\kappa t}\) is deliberately chosen so that it will turn out that whatever the value of \(\kappa\), the marginal distribution of \(x_t\) will be unchanged.
The solution to the SDE is given by
Fields:
-
rate(float) -
kappa(float) -
bdlp(CompoundPoissonProcess[D])
bdlp
pydantic-field
¶
Background driving Lévy process is a CompoundPoissonProcess with jump distribution D
intensity
property
¶
The intensity of the NGOU process is the intensity of the background driving Lévy process
characteristic_exponent
abstractmethod
¶
Characteristic exponent of a non-Gaussian OU process driven by a Lévy process \(Z\) with characteristic exponent \(\phi_Z\):
Source code in quantflow/sp/ou.py
sample_from_draws
¶
sample
abstractmethod
¶
Generate random Paths from the process.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
number of paths
TYPE:
|
time_horizon
|
time horizon
TYPE:
|
time_steps
|
number of time steps to arrive at horizon
TYPE:
|
Source code in quantflow/sp/base.py
characteristic
¶
Characteristic function at time t for a given input parameter u
The characteristic function represents the Fourier transform of the probability density function
where \(\phi\) is the characteristic exponent, which can be more easily computed for many processes.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
Time horizon
TYPE:
|
u
|
Characteristic function input parameter
TYPE:
|
Source code in quantflow/sp/base.py
convexity_correction
¶
analytical_std
¶
Analytical standard deviation of the process at time t
This has a closed form solution if the process has an analytical variance
analytical_mean
¶
analytical_variance
¶
analytical_pdf
¶
analytical_cdf
¶
marginal
¶
domain_range
¶
frequency_range
¶
Maximum frequency when calculating characteristic functions
Source code in quantflow/sp/base.py
support
¶
Support of the process at time t
Source code in quantflow/sp/base.py
integrated_log_laplace
abstractmethod
¶
The log-Laplace transform of the cumulative process:
| PARAMETER | DESCRIPTION |
|---|---|
t
|
time horizon
TYPE:
|
u
|
frequency
TYPE:
|
Source code in quantflow/sp/base.py
quantflow.sp.ou.GammaOU
pydantic-model
¶
Bases: NGOU[Exponential]
Gamma OU process is a non-Gaussian OU process where the background driving Lévy process is a compound Poisson process with exponential jumps
Fields:
-
rate(float) -
kappa(float) -
bdlp(CompoundPoissonProcess[D])
bdlp
pydantic-field
¶
Background driving Lévy process is a CompoundPoissonProcess with jump distribution D
intensity
property
¶
The intensity of the NGOU process is the intensity of the background driving Lévy process
create
classmethod
¶
Convenience constructor for GammaOU process
Source code in quantflow/sp/ou.py
characteristic_exponent
¶
Closed form of the NGOU characteristic exponent when the BDLP is a compound Poisson process with intensity \(\lambda\) and exponential jumps of decay \(\beta\):
Derivation. The characteristic function of the Exponential jumps is
so the BDLP unit-time characteristic exponent (CompoundPoissonProcess at \(t = 1\)) is
and \(\phi_Z(v)/v = -i\lambda / (\beta - iv)\). Substituting \(w = \beta - iv\) (so \(dv = i\, dw\)) in the NGOU integral gives
which combined with the drift term \(-iu\, x_0\, e^{-\kappa t}\) yields the closed form above.
Source code in quantflow/sp/ou.py
integrated_log_laplace
¶
Log-Laplace transform of the time-integrated Gamma-OU process.
where \(x_0\) is the initial rate, \(\lambda\) is the BDLP intensity and \(\beta\) the exponential jump decay.
Source code in quantflow/sp/ou.py
sample
¶
Source code in quantflow/sp/ou.py
analytical_mean
¶
Analytical mean of the Gamma-OU process at time \(t\).
which converges to the stationary mean \(\lambda / \beta\) as \(t \to \infty\).
Source code in quantflow/sp/ou.py
analytical_variance
¶
Analytical variance of the Gamma-OU process at time \(t\).
which converges to the stationary variance \(\lambda / \beta^2\) as \(t \to \infty\).
Source code in quantflow/sp/ou.py
analytical_pdf
¶
Stationary marginal density of the Gamma-OU process. The transient
density is not available in closed form; use pdf_from_characteristic
for finite \(t\).
Source code in quantflow/sp/ou.py
sample_from_draws
¶
characteristic
¶
Characteristic function at time t for a given input parameter u
The characteristic function represents the Fourier transform of the probability density function
where \(\phi\) is the characteristic exponent, which can be more easily computed for many processes.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
Time horizon
TYPE:
|
u
|
Characteristic function input parameter
TYPE:
|
Source code in quantflow/sp/base.py
convexity_correction
¶
analytical_std
¶
Analytical standard deviation of the process at time t
This has a closed form solution if the process has an analytical variance
analytical_cdf
¶
marginal
¶
domain_range
¶
frequency_range
¶
Maximum frequency when calculating characteristic functions
Source code in quantflow/sp/base.py
support
¶
Support of the process at time t