Processes¶
Stochastic processes driving the pricing engines.
processes
¶
Runtime source shim for the native itofin.processes submodule.
The real itofin.processes is a compiled submodule registered into
sys.modules by the extension; it wins at import time, so nothing here
runs. This file exists only so static type checkers resolve
from itofin.processes import ... from processes/__init__.pyi without a
reportMissingModuleSource warning.
Auto-generated by scripts/gen_submodule_shims.py from processes/__init__.pyi; do not edit or delete by hand.
BatesProcess
¶
BatesProcess(spot: SimpleQuote, risk_free: YieldTermStructure, dividend: YieldTermStructure, v0: float, kappa: float, theta: float, sigma: float, rho: float, lambda_: float, nu: float, delta: float)
Heston variance with independent constant-intensity lognormal jumps.
Retains live spot and yield curves for analytic pricing, not path generation.
Retain the market and validate eight finite Bates parameters.
Variance, mean reversion and variance volatility must be positive; correlation is in [-1, 1], and lambda_ and delta are nonnegative.
BlackScholesProcess
¶
BlackScholesProcess(spot: float, risk_free_rate: float, dividend_yield: float, volatility: float, reference_date: Date, day_counter: DayCounter)
A generalized Black-Scholes process, built from scalars or curve objects.
The Handle plumbing is assembled internally, so no handle crosses the binding boundary. The constructor takes the conventional (risk_free_rate, dividend_yield) order and places the two curves in the core's own order at a single call site.
Build a flat-market process from scalar inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spot
|
float
|
The spot level, held as a quote. |
required |
risk_free_rate
|
float
|
The flat risk-free rate, made into a curve compounded continuously on an annual frequency. |
required |
dividend_yield
|
float
|
The flat dividend yield, made into a curve on the same convention as the risk-free rate. |
required |
volatility
|
float
|
The flat Black volatility. |
required |
reference_date
|
Date
|
The date the three flat curves are anchored on. |
required |
day_counter
|
DayCounter
|
The day count the curves accrue on. |
required |
from_curves
staticmethod
¶
from_curves(spot: float, risk_free: YieldTermStructure, dividend: YieldTermStructure, vol: BlackVolTermStructure) -> BlackScholesProcess
Build a process from term-structure objects instead of scalars.
The three legs are bound by name and placed in the core's order at a single call site, the same risk-free/dividend argument-order footgun the scalar constructor guards against.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spot
|
float
|
The spot level, held as a quote. |
required |
risk_free
|
YieldTermStructure
|
The risk-free discount curve. |
required |
dividend
|
YieldTermStructure
|
The dividend curve. |
required |
vol
|
BlackVolTermStructure
|
The Black volatility surface. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BlackScholesProcess |
BlackScholesProcess
|
A process over the three supplied term structures. |
risk_free_rate
¶
Return the risk-free rate carried by the process.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The continuously compounded zero rate on the risk-free curve at the |
float
|
reference date. |
dividend_yield
¶
Return the dividend yield carried by the process.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The continuously compounded zero rate on the dividend curve at the |
float
|
reference date. |
G2Process
¶
Two correlated zero-level Gaussian factors, initially x=y=0.
Signed reversions and zero volatilities are supported. This is not a fitted short-rate model, curve, tree or pricing engine. Matrices are owned row lists. Diffusion uses rho*eta, correcting QuantLib's unequal-volatility defect.
Copy finite parameters; require nonnegative sigma/eta and rho in [-1,1].
drift
¶
Return the native drift at finite nonnegative time and two finite states.
diffusion
¶
Return the instantaneous two-by-two diffusion, one row per component.
expectation
¶
Return exact OU conditional means for finite nonnegative t and dt.
std_deviation
¶
Return the exact transition root, not entrywise standard deviations.
covariance
¶
Return exact conditional covariance, one row per state component.
apply
¶
Add two finite component changes; reject nonfinite sums.
evolve
¶
Evolve exactly using two independent standard Gaussian draws.
GJRGARCHProcess
¶
GJRGARCHProcess(spot: SimpleQuote, risk_free: YieldTermStructure, dividend: YieldTermStructure, daily_variance: float, omega: float, alpha: float, beta: float, gamma: float, lambda_: float, days_per_year: float = 252.0, scheme: str = 'FullTruncation')
GJR-GARCH diffusion approximation retaining live spot and yield curves.
Parameters daily_variance and omega use daily units. The state is
[spot, annual_variance], with initial annual variance equal to
daily_variance * days_per_year. Truncation schemes can return a negative
raw variance state; this is not a daily GJR recursion or a pricing model.
Retain spot and curves and validate finite admissible GJR parameters.
daily_variance
¶
Return initial daily variance, not the annualized state component.
drift
¶
Return log-spot and annual-variance drift at a two-component state.
diffusion
¶
Return the two-by-two diffusion matrix, one row per state component.
evolve
¶
Evolve a state with two supplied independent standard-normal draws.
time
¶
Convert a date using the risk-free curve's reference date and day count.
GeometricBrownianMotionProcess
¶
Constant-coefficient dX = mu * X * dt + volatility * X * dW process.
Finite signed states are supported. Discrete transitions use additive Euler,
not the exact lognormal scheme of itofin.simulate_gbm. A sufficiently large
draw can cross zero. Standard deviation retains the sign of the state,
matching native diffusion-based Euler transitions.
Copy finite initial state and drift, and finite nonnegative volatility.
drift
¶
Return mu * x for a finite state and nonnegative finite time.
expectation
¶
Return Euler expectation x + mu * x * dt, not the exact GBM mean.
variance
¶
Return Euler variance volatility**2 * x**2 * dt.
std_deviation
¶
Return signed Euler deviation volatility * x * sqrt(dt).
evolve
¶
Return Euler expectation plus signed deviation times a standard draw.
GsrProcess
¶
GsrProcess(times: Sequence[float], vols: Sequence[float], reversions: Sequence[float], t_measure: float)
Constant-volatility, signed constant-reversion Gaussian forward-measure process.
This is not a fitted or calibrated GSR model. Times are process years within [0,T]; date conversion and varying parameter grids are unsupported.
Copy a validated constant grid and finite nonnegative forward horizon.
Volatility count is time count plus one. Reversions contain one value or match volatility count. All repeated values must be identical. Grid times are finite, nonnegative and strictly increasing. Zero horizon is valid.
HestonProcess
¶
HestonProcess(risk_free_rate: float, dividend_yield: float, spot: float, v0: float, kappa: float, theta: float, sigma: float, rho: float, reference_date: Date, day_counter: DayCounter)
The square-root stochastic-variance process.
The two flat yield curves and the spot quote are assembled behind their handles internally, so no handle crosses the binding boundary.
Build the process from scalar market inputs and the five parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
risk_free_rate
|
float
|
The flat risk-free rate, made into a curve compounded continuously on an annual frequency. |
required |
dividend_yield
|
float
|
The flat dividend yield, made into a curve on the same convention as the risk-free rate. |
required |
spot
|
float
|
The spot level, held as a quote. |
required |
v0
|
float
|
The initial variance. |
required |
kappa
|
float
|
The mean-reversion speed. |
required |
theta
|
float
|
The long-run variance. |
required |
sigma
|
float
|
The volatility of variance. |
required |
rho
|
float
|
The spot/variance correlation. |
required |
reference_date
|
Date
|
The date the two flat curves are anchored on. |
required |
day_counter
|
DayCounter
|
The day count the curves accrue on. |
required |
v0
¶
Return the initial variance.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The initial variance v0. |
kappa
¶
Return the mean-reversion speed.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The mean-reversion speed kappa. |
theta
¶
Return the long-run variance.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The long-run variance theta. |
sigma
¶
Return the volatility of variance.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The volatility of variance sigma. |
rho
¶
Return the spot/variance correlation.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The spot/variance correlation rho. |
HullWhiteForwardProcess
¶
HullWhiteForwardProcess(curve: YieldTermStructure, a: float, sigma: float)
Standalone forward-measure short-rate process, not a calibrated pricing model.
The initial short rate is captured once. Fitting shifts and drift read the retained live curve. Horizon starts at zero; times are process years, not dates.
Retain the exact curve handle, with finite nonnegative reversion and volatility.
forward_measure_time
¶
Return the current finite nonnegative horizon.
set_forward_measure_time
¶
Replace the horizon and notify observers. Invalid values preserve state.
b
¶
Return B(t,maturity) for absolute endpoints; maturity before t is valid.
m_t
¶
Return M_T(s,t,maturity) for s <= t and any nonnegative absolute maturity.
drift
¶
Return forward-measure drift using the live curve and current horizon.
diffusion
¶
Return instantaneous volatility at valid t and x.
expectation
¶
Return the exact conditional mean using the retained live curve.
std_deviation
¶
Return conditional standard deviation.
variance
¶
Return variance, retaining the native Ornstein-Uhlenbeck small-speed branch.
evolve
¶
Evolve with one finite standard Gaussian draw.
Merton76Process
¶
Merton76Process(spot: SimpleQuote, risk_free: YieldTermStructure, dividend: YieldTermStructure, volatility: BlackVolTermStructure, jump_intensity: SimpleQuote, log_mean_jump: SimpleQuote, log_jump_volatility: SimpleQuote)
Merton's lognormal-jump model retaining observable market and jump inputs.
This process supports European pricing. Generic drift, diffusion and path generation are unavailable because a Gaussian step cannot represent jumps.
Retain the diffusion market and the three live lognormal-jump quotes.
Jump intensity and log-jump volatility must be finite and nonnegative; the log-jump mean must be finite. Invalid inputs raise ItofinError.
MfStateProcess
¶
Standalone Gaussian state process with immutable volatility buckets.
Not a fitted Markov-functional interest-rate model. Times are process years. Diffusion returns raw volatility; variance integrates sigma(s)^2 exp(2 a s). With no bucket times, variance uses unit volatility irrespective of vols[0].
Copy signed reversion, increasing times and nonnegative raw volatilities. Volatility count must exceed time count by one; all inputs must be finite.
diffusion
¶
Return raw sigma(t), not sigma(t) exp(reversion*t).
expectation
¶
Return the unchanged state after validating the interval.
std_deviation
¶
Return the exact conditional standard deviation.
variance
¶
Integrate sigma(s)^2 exp(2reversions) over the interval.
evolve
¶
Evolve using one finite standard Gaussian draw.