Skip to content

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.

v0

v0() -> float

Return the initial variance.

kappa

kappa() -> float

Return the variance mean-reversion speed.

theta

theta() -> float

Return the long-run variance.

sigma

sigma() -> float

Return the volatility of variance.

rho

rho() -> float

Return the spot/variance correlation.

lambda_

lambda_() -> float

Return the Poisson jump intensity.

nu

nu() -> float

Return the logarithmic jump mean.

delta

delta() -> float

Return the logarithmic jump standard deviation.

spot

spot() -> float

Return the current retained spot quote.

initial_values

initial_values() -> list[float]

Return the current spot and initial variance.

time

time(date: Date) -> float

Convert a date using the risk-free curve's clock.

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

risk_free_rate() -> float

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

dividend_yield() -> float

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

G2Process(a: float, sigma: float, b: float, eta: float, rho: float)

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].

size

size() -> int

Return the two state dimensions.

factors

factors() -> int

Return the two independent Gaussian factors.

x0

x0() -> float

Return initial x, always zero.

y0

y0() -> float

Return initial y, always zero.

a

a() -> float

Return signed x reversion.

sigma

sigma() -> float

Return x volatility.

b

b() -> float

Return signed y reversion.

eta

eta() -> float

Return y volatility.

rho

rho() -> float

Return instantaneous correlation.

initial_values

initial_values() -> list[float]

Return a fresh [0,0] state.

drift

drift(t: float, x: Sequence[float]) -> list[float]

Return the native drift at finite nonnegative time and two finite states.

diffusion

diffusion(t: float, x: Sequence[float]) -> list[list[float]]

Return the instantaneous two-by-two diffusion, one row per component.

expectation

expectation(t: float, x: Sequence[float], dt: float) -> list[float]

Return exact OU conditional means for finite nonnegative t and dt.

std_deviation

std_deviation(t: float, x: Sequence[float], dt: float) -> list[list[float]]

Return the exact transition root, not entrywise standard deviations.

covariance

covariance(t: float, x: Sequence[float], dt: float) -> list[list[float]]

Return exact conditional covariance, one row per state component.

apply

apply(x: Sequence[float], change: Sequence[float]) -> list[float]

Add two finite component changes; reject nonfinite sums.

evolve

evolve(t: float, x: Sequence[float], dt: float, draws: Sequence[float]) -> list[float]

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

daily_variance() -> float

Return initial daily variance, not the annualized state component.

omega

omega() -> float

Return the daily variance intercept.

alpha

alpha() -> float

Return the squared innovation coefficient.

beta

beta() -> float

Return the lagged variance coefficient.

gamma

gamma() -> float

Return the asymmetric innovation coefficient.

lambda_

lambda_() -> float

Return the innovation risk premium.

days_per_year

days_per_year() -> float

Return the daily-to-annual conversion factor.

discretization

discretization() -> str

Return the configured scheme name.

initial_values

initial_values() -> list[float]

Return current spot and initial annual variance.

drift

drift(t: float, state: Sequence[float]) -> list[float]

Return log-spot and annual-variance drift at a two-component state.

diffusion

diffusion(t: float, state: Sequence[float]) -> list[list[float]]

Return the two-by-two diffusion matrix, one row per state component.

evolve

evolve(t0: float, state: Sequence[float], dt: float, draws: Sequence[float]) -> list[float]

Evolve a state with two supplied independent standard-normal draws.

time

time(date: Date) -> float

Convert a date using the risk-free curve's reference date and day count.

GeometricBrownianMotionProcess

GeometricBrownianMotionProcess(initial: float, mu: float, volatility: float)

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.

x0

x0() -> float

Return the copied initial state.

mu

mu() -> float

Return the constant proportional drift coefficient.

volatility

volatility() -> float

Return the constant nonnegative volatility coefficient.

drift

drift(t: float, x: float) -> float

Return mu * x for a finite state and nonnegative finite time.

diffusion

diffusion(t: float, x: float) -> float

Return signed diffusion volatility * x.

expectation

expectation(t0: float, x: float, dt: float) -> float

Return Euler expectation x + mu * x * dt, not the exact GBM mean.

variance

variance(t0: float, x: float, dt: float) -> float

Return Euler variance volatility**2 * x**2 * dt.

std_deviation

std_deviation(t0: float, x: float, dt: float) -> float

Return signed Euler deviation volatility * x * sqrt(dt).

evolve

evolve(t0: float, x: float, dt: float, dw: float) -> float

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.

forward_measure_time

forward_measure_time() -> float

Return the current forward-measure horizon.

set_forward_measure_time

set_forward_measure_time(horizon: float) -> None

Replace the horizon and notify observers. Invalid values preserve state.

x0

x0() -> float

Return the zero initial state.

sigma

sigma(t: float) -> float

Return constant volatility at a valid process time.

reversion

reversion(t: float) -> float

Return signed reversion at a valid process time.

y

y(t: float) -> float

Return the auxiliary variance y(t).

g

g(t: float, end: float) -> float

Return G(t,end) for ordered endpoints inside the horizon.

drift

drift(t: float, x: float) -> float

Return the forward-measure drift.

diffusion

diffusion(t: float, x: float) -> float

Return instantaneous diffusion.

expectation

expectation(t: float, x: float, dt: float) -> float

Return the exact conditional mean.

std_deviation

std_deviation(t: float, x: float, dt: float) -> float

Return the exact conditional standard deviation.

variance

variance(t: float, x: float, dt: float) -> float

Return the exact conditional variance.

evolve

evolve(t: float, x: float, dt: float, dw: float) -> float

Evolve using one finite standard Gaussian draw.

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

v0() -> float

Return the initial variance.

Returns:

Name Type Description
float float

The initial variance v0.

kappa

kappa() -> float

Return the mean-reversion speed.

Returns:

Name Type Description
float float

The mean-reversion speed kappa.

theta

theta() -> float

Return the long-run variance.

Returns:

Name Type Description
float float

The long-run variance theta.

sigma

sigma() -> float

Return the volatility of variance.

Returns:

Name Type Description
float float

The volatility of variance sigma.

rho

rho() -> float

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.

x0

x0() -> float

Return the short rate captured at construction, unchanged by curve updates.

a

a() -> float

Return constant nonnegative mean reversion.

sigma

sigma() -> float

Return constant nonnegative volatility.

forward_measure_time

forward_measure_time() -> float

Return the current finite nonnegative horizon.

set_forward_measure_time

set_forward_measure_time(horizon: float) -> None

Replace the horizon and notify observers. Invalid values preserve state.

alpha

alpha(t: float) -> float

Return the fitting shift using the retained live curve.

b

b(t: float, maturity: float) -> float

Return B(t,maturity) for absolute endpoints; maturity before t is valid.

m_t

m_t(s: float, t: float, maturity: float) -> float

Return M_T(s,t,maturity) for s <= t and any nonnegative absolute maturity.

drift

drift(t: float, x: float) -> float

Return forward-measure drift using the live curve and current horizon.

diffusion

diffusion(t: float, x: float) -> float

Return instantaneous volatility at valid t and x.

expectation

expectation(t: float, x: float, dt: float) -> float

Return the exact conditional mean using the retained live curve.

std_deviation

std_deviation(t: float, x: float, dt: float) -> float

Return conditional standard deviation.

variance

variance(t: float, x: float, dt: float) -> float

Return variance, retaining the native Ornstein-Uhlenbeck small-speed branch.

evolve

evolve(t: float, x: float, dt: float, dw: float) -> float

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.

spot

spot() -> float

Return the current spot held by the diffusion market.

jump_intensity

jump_intensity() -> float

Return the current jump intensity.

log_mean_jump

log_mean_jump() -> float

Return the current mean of the logarithmic jump size.

log_jump_volatility

log_jump_volatility() -> float

Return the current standard deviation of the logarithmic jump size.

time

time(date: Date) -> float

Convert a date with the risk-free curve's reference date and day count.

MfStateProcess

MfStateProcess(reversion: float, times: Sequence[float], vols: Sequence[float])

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.

reversion

reversion() -> float

Return the signed exponential reversion parameter.

times

times() -> list[float]

Return a new copy of the right-continuous bucket boundaries.

volatilities

volatilities() -> list[float]

Return a new copy of the raw bucket volatilities.

x0

x0() -> float

Return zero, the initial process state.

drift

drift(t: float, x: float) -> float

Return zero after validating process time and state.

diffusion

diffusion(t: float, x: float) -> float

Return raw sigma(t), not sigma(t) exp(reversion*t).

expectation

expectation(t: float, x: float, dt: float) -> float

Return the unchanged state after validating the interval.

std_deviation

std_deviation(t: float, x: float, dt: float) -> float

Return the exact conditional standard deviation.

variance

variance(t: float, x: float, dt: float) -> float

Integrate sigma(s)^2 exp(2reversions) over the interval.

evolve

evolve(t: float, x: float, dt: float, dw: float) -> float

Evolve using one finite standard Gaussian draw.