hasquant
Safe HaskellNone
LanguageHaskell2010

QuantLib.Process

Synopsis

Types

Process hierarchy

data GenStochasticProcess p Source #

StochasticProcess
  ExtOUWithJumpsProcess
  GJRGARCHProcess
  HybridHestonHullWhiteProcess
  KlugeExtOUProcess
  LiborForwardModelProcess
  StochasticProcessArray
  G2Process
  G2ForwardProcess
  HestonProcess
    BatesProcess
  HestonSLVProcess
  StochasticProcess1D
    ExtendedOrnsteinUhlenbeckProcess
    HullWhiteForwardProcess
    HullWhiteProcess
    Merton76Process
    VarianceGammaProcess
    GeneralizedBlackScholesProcess
      BlackProcess

type StochasticProcess = GenStochasticProcess CStochasticProcess Source #

The root of the hierarchy shown under GenStochasticProcess.

type GenStochasticProcess1D p1d = GenStochasticProcess (AnyOf CStochasticProcess1D' p1d) Source #

A StochasticProcess1D or one of its leaves; see the hierarchy under GenStochasticProcess.

type StochasticProcess1D = GenStochasticProcess1D CStochasticProcess1D Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type GenGeneralizedBlackScholesProcess gbs = GenStochasticProcess1D (AnyOf CGeneralizedBlackScholesProcess' gbs) Source #

type ExtOUWithJumpsProcess = GenStochasticProcess CExtOUWithJumpsProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type ExtendedOrnsteinUhlenbeckProcess = GenStochasticProcess1D CExtendedOrnsteinUhlenbeckProcess Source #

A StochasticProcess1D; see the hierarchy under GenStochasticProcess.

type GJRGARCHProcess = GenStochasticProcess CGJRGARCHProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type GenHestonProcess hp = GenStochasticProcess (AnyOf CHestonProcess' hp) Source #

A HestonProcess or one of its leaves; see the hierarchy under GenStochasticProcess.

type HestonProcess = GenHestonProcess CHestonProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type HestonSLVProcess = GenStochasticProcess CHestonSLVProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type BatesProcess = GenHestonProcess CBatesProcess Source #

A HestonProcess; see the hierarchy under GenStochasticProcess.

type G2Process = GenStochasticProcess CG2Process Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type G2ForwardProcess = GenStochasticProcess CG2ForwardProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type HybridHestonHullWhiteProcess = GenStochasticProcess CHybridHestonHullWhiteProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type KlugeExtOUProcess = GenStochasticProcess CKlugeExtOUProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type LiborForwardModelProcess = GenStochasticProcess CLiborForwardModelProcess Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type StochasticProcessArray = GenStochasticProcess CStochasticProcessArray Source #

A StochasticProcess; see the hierarchy under GenStochasticProcess.

type VarianceGammaProcess = GenStochasticProcess1D CVarianceGammaProcess Source #

A StochasticProcess1D; see the hierarchy under GenStochasticProcess.

type Merton76Process = GenStochasticProcess1D CMerton76Process Source #

A StochasticProcess1D; see the hierarchy under GenStochasticProcess.

type HullWhiteProcess = GenStochasticProcess1D CHullWhiteProcess Source #

A StochasticProcess1D; see the hierarchy under GenStochasticProcess.

type HullWhiteForwardProcess = GenStochasticProcess1D CHullWhiteForwardProcess Source #

A StochasticProcess1D; see the hierarchy under GenStochasticProcess.

Discretization schemes

data ExtendedBlackScholesMertonProcessDiscretization Source #

Instances

Instances details
Enum ExtendedBlackScholesMertonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Read ExtendedBlackScholesMertonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Show ExtendedBlackScholesMertonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Eq ExtendedBlackScholesMertonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

data ExtendedOrnsteinUhlenbeckProcessDiscretization Source #

Instances

Instances details
Enum ExtendedOrnsteinUhlenbeckProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Read ExtendedOrnsteinUhlenbeckProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Show ExtendedOrnsteinUhlenbeckProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Eq ExtendedOrnsteinUhlenbeckProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

data HestonProcessDiscretization Source #

Instances

Instances details
Enum HestonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Read HestonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Show HestonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Eq HestonProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

data GJRGARCHProcessDiscretization Source #

Instances

Instances details
Enum GJRGARCHProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Read GJRGARCHProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Show GJRGARCHProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Eq GJRGARCHProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

data HybridHestonHullWhiteProcessDiscretization Source #

Instances

Instances details
Enum HybridHestonHullWhiteProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Read HybridHestonHullWhiteProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Show HybridHestonHullWhiteProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Eq HybridHestonHullWhiteProcessDiscretization Source # 
Instance details

Defined in QuantLib.Process

Constructors

Hierarchy conversion

Black-Scholes processes

blackProcess Source #

Arguments

:: GenQuote q

x0

-> GenYieldTermStructure y

riskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> ProcessDiscretization 
-> Bool

forceDiscretization

-> IO BlackProcess 

Black (1976) process for a forward or futures contract: d(ln S) = -sigma^2/2 dt + sigma dW.

blackScholesMertonProcess Source #

Arguments

:: GenQuote q

x0

-> GenYieldTermStructure y1

dividendTS

-> GenYieldTermStructure y2

riskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> ProcessDiscretization 
-> Bool

forceDiscretization

-> IO GeneralizedBlackScholesProcess 

Merton (1973) extension of Black-Scholes for a continuous-dividend-paying stock: d(ln S) = (r - q - sigma^2/2) dt + sigma dW.

blackScholesProcess Source #

Arguments

:: GenQuote q

x0

-> GenYieldTermStructure y

riskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> ProcessDiscretization 
-> Bool

forceDiscretization

-> IO GeneralizedBlackScholesProcess 

Black-Scholes (1973) process for a stock: d(ln S) = (r - sigma^2/2) dt + sigma dW.

extendedBlackScholesMertonProcess Source #

blackScholesMertonProcess with a choice of evolution scheme (Euler/Milstein/predictor-corrector) on top of the discretization argument.

garmanKohlhagenProcess Source #

Arguments

:: GenQuote q

x0

-> GenYieldTermStructure y1

foreignRiskFreeTS

-> GenYieldTermStructure y2

domesticRiskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> ProcessDiscretization 
-> Bool

forceDiscretization

-> IO GeneralizedBlackScholesProcess 

Garman-Kohlhagen (1983) process for an exchange rate: d(ln S) = (r - r_f - sigma^2/2) dt + sigma dW.

generalizedBlackScholesProcess Source #

Arguments

:: GenQuote q

x0

-> GenYieldTermStructure y1

dividendTS

-> GenYieldTermStructure y2

riskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> ProcessDiscretization 
-> Bool

forceDiscretization

-> IO GeneralizedBlackScholesProcess 

Generalized Black-Scholes process with separate dividend and risk-free curves: d(ln S) = (r - q - sigma^2/2) dt + sigma dW.

squareRootProcess Source #

square-root process: dx = a (b - x) dt + sigma sqrt(x) dW.

vegaStressedBlackScholesProcess Source #

Arguments

:: GenQuote q

x0

-> GenYieldTermStructure y1

dividendTS

-> GenYieldTermStructure y2

riskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> Double

lowerTimeBorderForStressTest

-> Double

upperTimeBorderForStressTest

-> Double

lowerAssetBorderForStressTest

-> Double

upperAssetBorderForStressTest

-> Double

stressLevel

-> ProcessDiscretization 
-> IO GeneralizedBlackScholesProcess 

blackScholesMertonProcess variant supporting local vega stress tests over a given time/asset border and stress level.

Other processes

batesProcess Source #

Arguments

:: GenYieldTermStructure y1

riskFreeTS

-> GenYieldTermStructure y2

dividendYield

-> GenQuote q

s0

-> Double

v0

-> Double

kappa

-> Double

theta

-> Double

sigma

-> Double

rho

-> Double

lambda

-> Double

nu

-> Double

delta

-> HestonProcessDiscretization 
-> IO BatesProcess 

square-root stochastic-volatility Bates process: a Heston process plus a compound Poisson jump component with log-normally distributed jump size.

extOuWithJumpsProcess Source #

Arguments

:: ExtendedOrnsteinUhlenbeckProcess 
-> Double

Y0

-> Double

beta

-> Double

jumpIntensity

-> Double

eta

-> IO ExtOUWithJumpsProcess 

Kluge model: an extended Ornstein-Uhlenbeck process plus an exponential-jump component, S = exp(X + Y) with dX = alpha (mu(t) - X) dt + sigma dW and dY = -beta Y dt + J dN. When the extended process is callback-backed, this result must remain inside the same continuation.

g2ForwardProcess Source #

Arguments

:: Double

a

-> Double

sigma

-> Double

b

-> Double

eta

-> Double

rho

-> Maybe (GenYieldTermStructure y)

termStructure

-> IO G2ForwardProcess 

T-forward-measure counterpart of g2Process: the two-factor G2++ short-rate model, with the simulated state again shifted so its components sum to the short rate.

g2Process Source #

Arguments

:: Double

a

-> Double

sigma

-> Double

b

-> Double

eta

-> Double

rho

-> Maybe (GenYieldTermStructure y)

termStructure

-> IO G2Process 

two-factor G2++ short-rate process, state shifted so its two OU components sum to the short rate; degenerates to a pair of zero-mean OU processes if no term structure is given.

gemanRoncoroniProcess Source #

Arguments

:: Double

x0

-> Double

alpha

-> Double

beta

-> Double

gamma

-> Double

delta

-> Double

eps

-> Double

zeta

-> Double

d

-> Double

k

-> Double

tau

-> Double

sig2

-> Double

a

-> Double

b

-> Double

theta1

-> Double

theta2

-> Double

theta3

-> Double

psi

-> IO StochasticProcess1D 

Geman-Roncoroni process, a mean-reverting jump-diffusion model for electricity spot prices with a seasonal deterministic mean and an asymmetric jump term.

geometricBrownianMotionProcess Source #

Arguments

:: Double

initialValue

-> Double

mue

-> Double

sigma

-> IO StochasticProcess1D 

geometric Brownian motion process: dS = mue S dt + sigma S dW.

gjrGarchProcess Source #

Arguments

:: GenYieldTermStructure y1

riskFreeRate

-> GenYieldTermStructure y2

dividendYield

-> GenQuote q

s0

-> Double

v0

-> Double

omega

-> Double

alpha

-> Double

beta

-> Double

gamma

-> Double

lambda

-> Double

daysPerYear

-> GJRGARCHProcessDiscretization 
-> IO GJRGARCHProcess 

stochastic-volatility GJR-GARCH(1,1) process; parameters are supplied as daily constants and annualized internally via daysPerYear.

hestonProcess Source #

Arguments

:: GenYieldTermStructure y1

riskFreeRate

-> Maybe (GenYieldTermStructure y2)

dividendYield

-> GenQuote q

s0

-> Double

v0

-> Double

kappa

-> Double

theta

-> Double

sigma

-> Double

rho

-> HestonProcessDiscretization 
-> IO HestonProcess 

dividendYield may be Nothing (an empty term-structure handle) -- required e.g. by integralHestonVarianceOptionEngine, which rejects a process with a non-empty dividend handle.

hestonSlvProcess Source #

Arguments

:: GenHestonProcess hp

hestonProcess

-> GenLocalVolTermStructure lv

leverageFct

-> Double

mixingFactor

-> IO HestonSLVProcess 

Two-factor Heston stochastic-local-volatility process using the supplied calibrated leverage function. It is a generic StochasticProcess, so it composes with path generators and the existing drift/diffusion operations.

hullWhiteProcess Source #

Hull-White one-factor short-rate process, fitted to the given initial term structure.

hybridHestonHullWhiteProcess Source #

three-factor hybrid model combining a Heston equity process with a Hull-White short-rate process, correlated via corrEquityShortRate.

klugeExtOuProcess Source #

Joint correlated Kluge (extOuWithJumpsProcess) and extended Ornstein-Uhlenbeck process. When either input retains a Haskell callback, this result must remain inside that callback's scope.

withExtendedOrnsteinUhlenbeckProcess Source #

An extended Ornstein-Uhlenbeck process dx = speed*(b(t) - x)dt + sigma*dW with an arbitrary deterministic mean-reversion level b, usable with pathGenerator. The FunPtr backing b is kept alive only for the continuation's duration. The process and any dependent process must not escape it (same rule as withDerivedQuote).

linearSeasonalOrnsteinUhlenbeckProcess Source #

Arguments

:: Double

speed

-> Double

sigma (volatility)

-> Double

x0

-> Double

a

-> Double

k (linear trend)

-> Double

c (seasonal amplitude)

-> Double

phase

-> ExtendedOrnsteinUhlenbeckProcessDiscretization 
-> Double

intEps

-> IO ExtendedOrnsteinUhlenbeckProcess 

An extended Ornstein-Uhlenbeck process with the Lucia-Schwartz-style level b(t) = a + k*t + c*sin(2*pi*t + phase), computed natively. Setting k = c = 0 gives a constant level and c = 0 gives a linear trend.

liborForwardModelProcess Source #

Arguments

:: Word

size

-> GenIborIndex ibor 
-> IO LiborForwardModelProcess 

Libor market model process, evolving size forward rates of index under the rolling forward measure with a predictor-corrector step.

merton76Process Source #

Arguments

:: GenQuote q1

stateVariable

-> GenYieldTermStructure y1

dividendTS

-> GenYieldTermStructure y2

riskFreeTS

-> GenBlackVolTermStructure bv

blackVolTS

-> GenQuote q2

jumpInt

-> GenQuote q3

logJMean

-> GenQuote q4

logJVol

-> ProcessDiscretization 
-> IO Merton76Process 

Merton (1976) jump-diffusion process: a Black-Scholes process plus a log-normal jump component with Poisson jump intensity jumpInt.

ornsteinUhlenbeckProcess Source #

Arguments

:: Double

speed

-> Double

vol

-> Double

x0

-> Double

level

-> IO StochasticProcess1D 

Ornstein-Uhlenbeck process: dx = a (level - x) dt + sigma dW.

varianceGammaProcess Source #

Arguments

:: GenQuote q

s0

-> GenYieldTermStructure y1

dividendYield

-> GenYieldTermStructure y2

riskFreeRate

-> Double

sigma

-> Double

nu

-> Double

theta

-> IO VarianceGammaProcess 

Variance Gamma process: a Brownian motion db = theta dt + sigma dW time-changed by an independent Gamma process with mean 1 and variance rate nu.

stochasticProcessArray Source #

array of correlated 1-D stochastic processes, driven by a joint correlation matrix.

Mutators

class HasForwardMeasureTime a where Source #

Forward-measure processes that require a maturity time before simulation.

Methods

setForwardMeasureTime :: a -> Double -> IO () Source #

Inspectors

Process dynamics

apply Source #

Arguments

:: GenStochasticProcess p 
-> [Double]

x0

-> [Double]

dx

-> IO [Double] 

applies an increment dx to a state x0 in the process's own state space -- not always plain addition (a log-variable process exponentiates, for instance), which is why it is a method rather than a caller-side zipWith (+).

covariance :: GenStochasticProcess p -> Double -> [Double] -> Double -> IO (Matrix Double) Source #

the covariance matrix of the process over dt given state x0 at time t0; equals stdDeviation * transpose stdDeviation.

diffusion :: GenStochasticProcess p -> Double -> [Double] -> IO (Matrix Double) Source #

the diffusion part of the process's SDE at state x and time t, i.e. sigma(t, x_t) in dx_t = mu(t, x_t) dt + sigma(t, x_t) dW_t.

drift Source #

Arguments

:: GenStochasticProcess p 
-> Double

t

-> [Double]

x

-> IO [Double] 

the drift part of the process's SDE at state x and time t, i.e. mu(t, x_t) in dx_t = mu(t, x_t) dt + sigma(t, x_t) dW_t.

evolve Source #

Arguments

:: GenStochasticProcess p 
-> Double

t0

-> [Double]

x0

-> Double

dt

-> [Double]

dw

-> IO [Double] 

one discretized step of the process: the state at t0+dt given state x0 at t0 and the standard-normal draws dw (one per factors).

This crosses the FFI boundary once per timestep, so it is not the way to generate many paths -- use pathGenerator for that, which drives the same evolve entirely inside QuantLib. Reach for this when Haskell has to own the path logic (path-dependent state, early termination, a custom draw source via gaussianRsg) while QuantLib keeps owning the process's discretization scheme.

expectation Source #

Arguments

:: GenStochasticProcess p 
-> Double

t0

-> [Double]

x0

-> Double

dt

-> IO [Double] 

E[x_(t0+dt) | x_t0 = x0], the expected state at t0+dt given state x0 at time t0.

stdDeviation :: GenStochasticProcess p -> Double -> [Double] -> Double -> IO (Matrix Double) Source #

the standard deviation matrix of the process over dt given state x0 at time t0, i.e. a square root of covariance -- the factor a simulated normal draw is multiplied by in one exact-scheme step. Pairs with expectation: x_(t0+dt) = expectation + stdDeviation * dw for a process whose discretization is exact in that sense.

pdf Source #

Arguments

:: GenHestonProcess hp

process

-> Double

x

-> Double

v

-> Double

t

-> Double

eps

-> IO Double 

Probability density of (x = ln S, v) at time t, evaluated via the Heston characteristic-function inversion (the same machinery as analyticPDFHestonEngine). eps is the requested integration accuracy.

discountBond Source #

Arguments

:: LiborForwardModelProcess 
-> [Double]

rates

-> IO [Double] 

the cumulative discount factors implied by one simulated vector of forward rates: element i discounts from the end of accrual period i back to the process's start, i.e. scanl1 (*) [1 / (1 + r_i tau_i)] over accrualTimes -- not the individual one-period factors.

Process state

factors :: GenStochasticProcess p -> IO Word Source #

the number of independent Brownian factors driving a stochastic process -- e.g. 2 for g2Process, matching its state size; used to size a pathGenerator's underlying sequence generator (process->factors() * steps, mirroring upstream's own usage).

initialValues :: GenStochasticProcess p -> IO [Double] Source #

the process's state at time 0, e.g. (0, 0) for a curveless g2Process or (phi(0), 0) once a term structure is given.

fixingDates :: LiborForwardModelProcess -> IO [Day] Source #

the reset (fixing) dates of the forward rates this process evolves

fixingTimes :: LiborForwardModelProcess -> IO [Double] Source #

the reset (fixing) times of the forward rates this process evolves, in the process's own day count fraction from the evaluation date

cashFlows Source #

Arguments

:: LiborForwardModelProcess 
-> Double

amount

-> IO Leg 

the leg of Ibor coupons (notional amount each) this process's forward rates reset -- used e.g. to build the cap this process prices via liborForwardModel

index :: LiborForwardModelProcess -> IO IborIndex Source #

the underlying IborIndex this process was constructed with

accrualTimes :: LiborForwardModelProcess -> IO [(Double, Double)] Source #

the (start, end) accrual times of the forward rates this process evolves, in its own day count fraction from the evaluation date; their difference is the accrual period a caplet payoff is scaled by.

Short-rate and forward-measure quantities

class HasPhi a where Source #

Two-factor short-rate processes with the same deterministic curve-fitting offset.

Methods

phi :: a -> Double -> IO Double Source #

Instances

Instances details
HasPhi G2ForwardProcess Source # 
Instance details

Defined in QuantLib.Process

HasPhi G2Process Source # 
Instance details

Defined in QuantLib.Process

Methods

phi :: G2Process -> Double -> IO Double Source #

class HasShortRate a where Source #

Two-factor processes whose simulated state maps to the short rate in the same way.

Methods

shortRate :: a -> Double -> Double -> Double -> Double Source #

Instances

Instances details
HasShortRate G2ForwardProcess Source # 
Instance details

Defined in QuantLib.Process

HasShortRate G2Process Source # 
Instance details

Defined in QuantLib.Process

class HasAlpha a where Source #

Hull--White processes exposing the deterministic curve-fitting offset.

Methods

alpha :: a -> Double -> IO Double Source #

Instances

Instances details
HasAlpha HullWhiteForwardProcess Source # 
Instance details

Defined in QuantLib.Process

HasAlpha HullWhiteProcess Source # 
Instance details

Defined in QuantLib.Process

bFunction Source #

the Hull-White B(t, T) = (1 - exp(-a (T - t))) / a factor of the affine discount-bond formula P(t, T) = A(t, T) exp(-B(t, T) r_t).

mFunction Source #

the T-forward-measure drift adjustment M_T(s, t, T) the process applies between s and t when the numeraire is the T-maturity zero bond.

numeraire Source #

the T-forward-measure numeraire of a hybridHestonHullWhiteProcess at time t in state x: P(t, T, x!!2) / P(0, T), where T is the process's forward-measure time and P is the Hull-White discount bond implied by the simulated short-rate factor.

The state is [S, v, r] -- spot, variance and the Hull-White factor, in the order initialValues returns -- and only x!!2 is read. This is not a bank account: to turn a simulated time-t payoff into a present value, divide it by this numeraire and multiply by the curve's own discount ts T.

T is captured when the hybrid process is constructed, from the hullWhiteForwardProcess's forward-measure time -- so setForwardMeasureTime must be called on that process before hybridHestonHullWhiteProcess, not after.

thetaAt Source #

Arguments

:: GeneralizedBlackScholesProcess 
-> Double

value

-> Double

delta

-> Double

gamma

-> IO Double 

default theta calculation for Black-Scholes options