hasquant
Safe HaskellNone
LanguageHaskell2010

QuantLib.Model

Description

Historical volatility estimators bound here (ql/models/volatility, ql/prices.hpp) -- Garch11, GarmanKlass/Parkinson, ConstantEstimator, SimpleLocalEstimator -- are distinct from QuantLib.TermStructure.Volatility, which covers forward-looking implied-volatility surfaces and smiles. None of these classes have any calculations of their own beyond a single calculate call and are never needed as an argument type elsewhere, so only Garch11 -- whose calibrated state (alpha etc.) is queried repeatedly -- gets a dedicated Haskell type; every GarmanKlass variant, ConstantEstimator, and SimpleLocalEstimator are bound as a single construct-and-calculate function each.

Synopsis

Types

Model hierarchy

data GenCalibratedModel m Source #

CalibratedModel
 LiborForwardModel + AffineModel
 GJRGARCHModel
 PiecewiseTimeDependentHestonModel
 RoughHestonModel
 HestonModel
   BatesModel
     BatesDetJumpModel
   BatesDoubleExpModel
     BatesDoubleExpDetJumpModel
 ShortRateModel
   G2 + AffineModel
   OneFactorAffineModel + AffineModel
     HullWhite + AffineModel
 Gsr + Gaussian1dModel
 MarkovFunctional + Gaussian1dModel

type CalibratedModel = GenCalibratedModel CCalibratedModel Source #

The root of the hierarchy shown under GenCalibratedModel.

type GenShortRateModel sm = GenCalibratedModel (AnyOf CShortRateModel' sm) Source #

A ShortRateModel or one of its leaves; see the hierarchy under GenCalibratedModel.

type ShortRateModel = GenShortRateModel CShortRateModel Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type GenOneFactorAffineModel om = GenShortRateModel (AnyOf COneFactorAffineModel' om) Source #

An OneFactorAffineModel or one of its leaves; see the hierarchy under GenCalibratedModel.

type OneFactorAffineModel = GenOneFactorAffineModel COneFactorAffineModel Source #

A ShortRateModel; see the hierarchy under GenCalibratedModel.

type G2 = GenShortRateModel CG2 Source #

A ShortRateModel; see the hierarchy under GenCalibratedModel.

type GenHestonModel hm = GenCalibratedModel (AnyOf CHestonModel' hm) Source #

A HestonModel or one of its leaves; see the hierarchy under GenCalibratedModel.

type HestonModel = GenHestonModel CHestonModel Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type RoughHestonModel = GenCalibratedModel CRoughHestonModel Source #

A CalibratedModel with its concrete native interface preserved.

type PiecewiseTimeDependentHestonModel = GenCalibratedModel CPiecewiseTimeDependentHestonModel Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type GenBatesModel bm = GenHestonModel (AnyOf CBatesModel' bm) Source #

A BatesModel or one of its leaves; see the hierarchy under GenCalibratedModel.

type BatesModel = GenBatesModel CBatesModel Source #

A HestonModel; see the hierarchy under GenCalibratedModel.

type BatesDetJumpModel = GenBatesModel CBatesDetJumpModel Source #

A BatesModel; see the hierarchy under GenCalibratedModel.

type GenBatesDoubleExpModel bdem = GenHestonModel (AnyOf CBatesDoubleExpModel' bdem) Source #

A BatesDoubleExpModel or one of its leaves; see the hierarchy under GenCalibratedModel.

type BatesDoubleExpModel = GenBatesDoubleExpModel CBatesDoubleExpModel Source #

A HestonModel; see the hierarchy under GenCalibratedModel.

type BatesDoubleExpDetJumpModel = GenBatesDoubleExpModel CBatesDoubleExpDetJumpModel Source #

A BatesDoubleExpModel; see the hierarchy under GenCalibratedModel.

type GJRGARCHModel = GenCalibratedModel CGJRGARCHModel Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type Gaussian1dModel = Standalone CGaussian1dModel' Source #

type Gsr = GenCalibratedModel CGsr Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type MarkovFunctional = GenCalibratedModel CMarkovFunctional Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type LiborForwardModel = GenCalibratedModel CLiborForwardModel Source #

A CalibratedModel; see the hierarchy under GenCalibratedModel.

type HestonSLVMCModel = Standalone CHestonSLVMCModel' Source #

type HestonSLVFDMModel = Standalone CHestonSLVFDMModel' Source #

type AffineModel = Standalone CAffineModel' Source #

type ShortRateDynamics = Standalone CShortRateDynamics' Source #

The two-factor short-rate dynamics (state variables x, y with r_t = phi(t) + x_t + y_t) underlying a G2 model, as returned by TwoFactorModel::dynamics().

Historical volatility estimators

Calibration helpers

data GenCalibrationHelper ch Source #

CalibrationHelper
  BlackCalibrationHelper*
    SwaptionHelper

type CalibrationHelper = GenCalibrationHelper CCalibrationHelper Source #

The root of the hierarchy shown under GenCalibrationHelper.

type GenBlackCalibrationHelper bch = GenCalibrationHelper (AnyOf CBlackCalibrationHelper' bch) Source #

A BlackCalibrationHelper or one of its leaves; see the hierarchy under GenCalibrationHelper.

type BlackCalibrationHelper = GenBlackCalibrationHelper CBlackCalibrationHelper Source #

A CalibrationHelper; see the hierarchy under GenCalibrationHelper.

type BrownianGeneratorFactory = Standalone CBrownianGeneratorFactory' Source #

Configuration

data SobolBrownianOrdering Source #

Sobol Brownian-bridge coordinate ordering.

Constructors

Factors 
Steps 
Diagonal 

Instances

Instances details
Bounded SobolBrownianOrdering Source # 
Instance details

Defined in QuantLib.Model

Enum SobolBrownianOrdering Source # 
Instance details

Defined in QuantLib.Model

Read SobolBrownianOrdering Source # 
Instance details

Defined in QuantLib.Model

Show SobolBrownianOrdering Source # 
Instance details

Defined in QuantLib.Model

Eq SobolBrownianOrdering Source # 
Instance details

Defined in QuantLib.Model

data HestonSLVGreensAlgorithm Source #

Initial-density approximation used by the Heston SLV Fokker--Planck calibrator.

Instances

Instances details
Bounded HestonSLVGreensAlgorithm Source # 
Instance details

Defined in QuantLib.Model

Enum HestonSLVGreensAlgorithm Source # 
Instance details

Defined in QuantLib.Model

Read HestonSLVGreensAlgorithm Source # 
Instance details

Defined in QuantLib.Model

Show HestonSLVGreensAlgorithm Source # 
Instance details

Defined in QuantLib.Model

Eq HestonSLVGreensAlgorithm Source # 
Instance details

Defined in QuantLib.Model

data HestonSLVVarianceTransformation Source #

Variance-coordinate transformation used by the Heston SLV Fokker--Planck calibrator.

Constructors

Plain 
Power 
Log 

Instances

Instances details
Bounded HestonSLVVarianceTransformation Source # 
Instance details

Defined in QuantLib.Model

Enum HestonSLVVarianceTransformation Source # 
Instance details

Defined in QuantLib.Model

Read HestonSLVVarianceTransformation Source # 
Instance details

Defined in QuantLib.Model

Show HestonSLVVarianceTransformation Source # 
Instance details

Defined in QuantLib.Model

Eq HestonSLVVarianceTransformation Source # 
Instance details

Defined in QuantLib.Model

data HestonSLVFDMLogEntry Source #

A copied FDM diagnostic snapshot. Coordinates are the native mesher coordinates: the spot axis is log-spot and the variance axis follows hestonSlvVarianceTransformation. Density rows correspond to variance coordinates and columns to log-spot coordinates.

type LfmHullWhiteParameterization = QlLfmHullWhiteParameterization Source #

data SwaptionSpan Source #

A swaption helper's exercise and underlying-swap span.

Constructors

SpanTenors !(Word, TimeUnit) !(Word, TimeUnit)

maturity, length

SpanFromDate !Day !(Word, TimeUnit)

exerciseDate, length

SpanDates !Day !Day

exerciseDate, endDate

Instances

Instances details
Show SwaptionSpan Source # 
Instance details

Defined in QuantLib.Model

Eq SwaptionSpan Source # 
Instance details

Defined in QuantLib.Model

Constructors

Hierarchy and secondary-interface conversion

class AsAffineModel model where Source #

Models that can be materialized as QuantLib's secondary AffineModel interface. The result owns a shared handle to the same underlying model.

Methods

asAffineModel :: model -> IO AffineModel Source #

class AsGaussian1dModel model where Source #

Models that can be materialized as QuantLib's secondary Gaussian1dModel interface. The result owns a shared handle to the same underlying model.

Model construction

batesModel :: BatesProcess -> IO BatesModel Source #

Bates stochastic-volatility model: extends Heston with jumps in the underlying's return process.

blackKarasinski Source #

Arguments

:: GenYieldTermStructure y 
-> Double

y

-> Double

sigma

-> IO ShortRateModel 

Black-Karasinski short-rate model: d(ln r) = (theta(t) - a ln r) dt + sigma dW, with constant reversion a and volatility sigma.

coxIngersollRoss Source #

Arguments

:: Double

r0

-> Double

theta

-> Double

k

-> Double

sigma

-> Bool

withFellerConstraint

-> IO OneFactorAffineModel 

Cox-Ingersoll-Ross short-rate model: dr = k(theta - r) dt + sigma sqrt(r) dW.

extendedCoxIngersollRoss Source #

Arguments

:: GenYieldTermStructure y 
-> Double

theta

-> Double

k

-> Double

sigma

-> Double

x0

-> Bool

withFellerConstraint

-> IO OneFactorAffineModel 

Extended CIR model: adds a deterministic term-structure-fitting shift to a standard Cox-Ingersoll-Ross process.

g2 Source #

Arguments

:: GenYieldTermStructure y 
-> Double

y

-> Double

sigma

-> Double

b

-> Double

eta

-> Double

rho

-> IO G2 

Two-additive-factor Gaussian (G2) short-rate model: the sum of two correlated Ornstein-Uhlenbeck factors.

generalizedHullWhite Source #

Arguments

:: GenYieldTermStructure y 
-> NonEmpty (Day, Double)

speedstructure

-> NonEmpty (Day, Double)

volstructure

-> IO ShortRateModel 

Generalized Hull-White model: like hullWhite, but reversion and volatility are piecewise-linear functions of time given at speedstructure/volstructure dates.

gjrGarchModel :: GJRGARCHProcess -> IO GJRGARCHModel Source #

GJR-GARCH stochastic-volatility model, extending GARCH(1,1) with an asymmetric response to negative return shocks.

hestonModel :: GenHestonProcess hp -> IO HestonModel Source #

Heston stochastic-volatility model, calibrated from a HestonProcess.

roughHestonModel Source #

Arguments

:: GenHestonProcess hp

process

-> Double

hurst

-> IO RoughHestonModel 

Rough Heston volatility model (1.44). Hurst is constrained to [0, 0.5]; 0.5 is classical Heston.

mtBrownianGeneratorFactory Source #

Arguments

:: Word

seed

-> IO BrownianGeneratorFactory 

Pseudo-random Mersenne-Twister Brownian increments for SLV Monte-Carlo calibration. Use a fixed nonzero seed for reproducible calibration output; QuantLib treats zero as entropy.

sobolBrownianGeneratorFactory Source #

Arguments

:: SobolBrownianOrdering

ordering

-> Word

seed

-> SobolDirectionIntegers

directionIntegers

-> IO BrownianGeneratorFactory 

Low-discrepancy Sobol Brownian increments for SLV Monte-Carlo calibration. Supply a fixed nonzero seed to make the resulting leverage function reproducible.

hestonSlvMcModel Source #

Arguments

:: GenLocalVolTermStructure lv

localVol

-> GenHestonModel hm

hestonModel

-> BrownianGeneratorFactory

brownianGeneratorFactory

-> Day

endDate

-> Word

timeStepsPerYear

-> Word

nBins

-> Word

calibrationPaths

-> [Day]

mandatoryDates

-> Double

mixingFactor

-> IO HestonSLVMCModel 

Monte-Carlo calibration of a Heston stochastic-local-volatility leverage function. The trailing arguments mirror QuantLib's defaults explicitly; mandatoryDates are inserted into the calibration time grid.

hestonSlvFdmModel :: GenLocalVolTermStructure lv -> GenHestonModel hm -> Day -> HestonSLVFokkerPlanckFdmParams -> Bool -> [Day] -> Double -> IO HestonSLVFDMModel Source #

Fokker--Planck finite-difference calibration of a Heston stochastic-local-volatility leverage function. logging retains diagnostic density snapshots for hestonSlvFdmLogEntries; mandatoryDates are added to its adaptive time grid.

hullWhite Source #

Arguments

:: GenYieldTermStructure y 
-> Double

a (mean reversion)

-> Double

sigma

-> IO HullWhite 

Single-factor Hull-White (extended Vasicek) short-rate model: dr = (theta(t) - a r) dt + sigma dW, fitted to the given term structure.

varianceGammaModel :: VarianceGammaProcess -> IO CalibratedModel Source #

Variance Gamma model for the underlying's log-return process (Madan-Carr-Chang).

vasicek Source #

Arguments

:: Double

r0

-> Double

a

-> Double

b

-> Double

sigma

-> Double

lambda

-> IO OneFactorAffineModel 

Vasicek short-rate model: dr = a(b - r) dt + sigma dW, with an optional risk premium lambda.

liborForwardModel :: LiborForwardModelProcess -> LmVolatilityModel -> LmCorrelationModel -> IO LiborForwardModel Source #

Libor market (BGM) forward-rate model, built from a LiborForwardModelProcess plus volatility and correlation models.

lfmHullWhiteParameterization Source #

Hull-White caplet-volatility parameterization for a Libor forward model. The correlation matrix and factor count are explicit, mirroring QuantLib's defaulted constructor arguments; pass an empty matrix and 1 for its standard one-factor default.

gsr :: GenYieldTermStructure y -> GenQuote q1 -> [(Day, GenQuote q1)] -> GenQuote q2 -> Double -> IO Gsr Source #

One-factor GSR model (formulated in the forward measure), with an initial volatility and piecewise-constant changes at the given dates, plus a single constant reversion.

gsrWithReversions :: GenYieldTermStructure y -> (GenQuote q1, GenQuote q2) -> [(Day, (GenQuote q1, GenQuote q2))] -> Double -> IO Gsr Source #

One-factor GSR model with a piecewise-constant reversion as well as volatility: the initial (volatility, reversion) pair holds until the first step date, and each step date starts a new pair. calibrateReversionsIterative needs this form, one reversion per calibration helper.

markovFunctional Source #

Arguments

:: GenYieldTermStructure y 
-> Double

reversion

-> Double

initial volatility

-> [(Day, Double)]

subsequent volatility steps

-> GenSwaptionVolatilityStructure sv 
-> NonEmpty (Day, (Word, TimeUnit))

swaption expiry/tenor calibration points

-> GenSwapIndex sidx

swapIndexBase

-> Word

yGridPoints

-> IO MarkovFunctional 

Markov-functional interest-rate model, calibrated to a swaption volatility cube against swapIndexBase.

markovFunctionalCaplet :: GenYieldTermStructure y -> Double -> Double -> [(Day, Double)] -> GenOptionletVolatilityStructure ov -> NonEmpty Day -> GenIborIndex ibor -> Word -> IO MarkovFunctional Source #

Markov-functional interest-rate model, calibrated to a caplet volatility structure against iborIndex.

garch11 Source #

Arguments

:: Double

alpha

-> Double

beta

-> Double

vl (long-term volatility)

-> IO Garch11 

Direct-parameter GARCH(1,1) model: vl is the long-term (unconditional) volatility: the model's persistence gamma = 1 - alpha - beta and omega = vl * gamma are derived from it. Does not calibrate; use garch11Calibrated to fit alpha/beta/vl to an observed series.

garch11Calibrated Source #

Arguments

:: NonEmpty (Day, Double)

observed return series

-> Garch11Mode 
-> IO Garch11 

Calibrates a GARCH(1,1) model to an observed return series via maximum likelihood. All four Garch11Mode values converge to the same maximum-likelihood fit for a well-behaved series -- they differ only in the initial guess (MomentMatchingGuess/GammaGuess), or run both and keep the better (BestOfTwo, the upstream default) or optimize from each in turn (DoubleOptimization). There is no way from Haskell to supply a custom OptimizationMethod/EndCriteria or to re-calibrate an existing model in place (upstream's calibrate overloads are mutators on an already-constructed object); construct a fresh model if a different fit is needed.

Calibration helpers

capHelper Source #

Arguments

:: (Word, TimeUnit)

length

-> GenQuote q

volatility

-> GenIborIndex ibor 
-> Frequency

fixedLegFrequency

-> DayCounter 
-> Bool

includeFirstSwaplet

-> GenYieldTermStructure y 
-> CalibrationErrorType 
-> VolatilityType

type

-> Double

shift

-> IO BlackCalibrationHelper 

Calibration helper for an at-the-money interest-rate cap.

hestonModelHelper Source #

Arguments

:: (Word, TimeUnit)

maturity

-> Calendar 
-> GenQuote q1

s0

-> Double

strikePrice

-> GenQuote q2

volatility

-> GenYieldTermStructure y1

riskFreeRate

-> GenYieldTermStructure y2

dividendYield

-> CalibrationErrorType 
-> IO BlackCalibrationHelper 

Calibration helper for the Heston model, from a European option's market volatility.

swaptionHelper :: SwaptionSpan -> GenQuote q -> GenIborIndex ibor -> (Word, TimeUnit) -> DayCounter -> DayCounter -> GenYieldTermStructure y -> CalibrationErrorType -> Maybe Double -> Double -> VolatilityType -> Double -> Maybe Word -> RateAveragingType -> IO SwaptionHelper Source #

Calibration helper for a swaption, over the given exercise/underlying span.

Mutators

setCovarParam Source #

installs the covariance parameterization a LiborForwardModelProcess evolves under.

Mandatory before the process is used for anything dynamic: a freshly constructed liborForwardModelProcess holds no parameterization, and drift, diffusion, evolve, factors and pathGenerator all dereference it. discountBond, the fixing/accrual times and cashFlows do not, and work without it.

calibrate Source #

Arguments

:: GenCalibratedModel m 
-> NonEmpty (GenCalibrationHelper ch, Double)

(instrument, weight)

-> OptimizationMethod 
-> EndCriteria 
-> Maybe Constraint 
-> [Bool]

fixParameters, e.g. fixedReversion; [] leaves nothing fixed

-> IO () 

Calibrate to a set of market instruments (caps/swaptions) An additional constraint can be passed which must be satisfied in addition to the constraints of the model.

calibrateVolatilitiesIterative :: Gsr -> [GenBlackCalibrationHelper bch] -> OptimizationMethod -> EndCriteria -> Maybe Constraint -> [Double] -> IO () Source #

Iteratively calibrates the volatility step values, one at a time, to the given helpers (assumed to have step dates matching the model's volatility step dates).

calibrateReversionsIterative :: Gsr -> [GenBlackCalibrationHelper bch] -> OptimizationMethod -> EndCriteria -> Maybe Constraint -> [Double] -> IO () Source #

Iteratively calibrates the reversions, one at a time: reversion i is fitted to helper i with every other parameter held. The model needs one reversion per helper at least, so build it with gsrWithReversions. The end criteria reflect only the last calibration.

A swaption's price depends on the reversion over its swap's life, so helper i should exercise inside reversion interval i and span it. Helpers expiring at the volatility step dates leave the fit ill-conditioned, and alternating with calibrateVolatilitiesIterative can diverge.

moveVolatility Source #

Arguments

:: Gsr 
-> Word

i

-> IO [Bool] 

The calibration mask (calibrate's fixParameters) that fixes every model parameter except the volatility at step index i (0-based) -- a ready-made fixParameters argument for calibrating that one volatility in isolation.

moveReversion Source #

Arguments

:: Gsr 
-> Word

i

-> IO [Bool] 

The calibration mask that fixes every model parameter except the reversion at index i (0-based) -- the reversion counterpart of moveVolatility. Only index 0 exists unless the model was built by gsrWithReversions.

setPricingEngine :: GenBlackCalibrationHelper bch -> GenPricingEngine pe -> IO () Source #

Sets the pricing engine used to compute this calibration helper's model value.

setParams Source #

Arguments

:: GenCalibratedModel m 
-> [Double]

params

-> IO () 

Replace the arguments on which calibration is done, in the order params returns them, and notify the model's observers, so engines on it reprice. An array whose length differs from params' throws and leaves the model unchanged; the model's constraint is not checked. A later calibrate starts from these values.

Inspectors

Pricing and rate calculations

discount Source #

Arguments

:: AffineModel 
-> Double

t

-> IO Double 

Discount factor at time t under the model's own fitted curve -- AffineModel::discount. Not pure: depends on the model's YieldTermStructure handle, which can be relinked after construction (see discountBond below for the same caveat).

discountBond Source #

Arguments

:: AffineModel 
-> Double

now

-> Double

maturity

-> [Double]

factors

-> IO Double 

Price of a discount bond paying 1 at maturity, given the model's state factors at time now -- AffineModel::discountBond(Time,Time,Array). factors is model-specific: a one-element list of the short rate for OneFactorAffineModel/HullWhite, a two-element list for G2, or ignored by LiborForwardModel. Not pure for the same relinkable-curve reason as discount.

discountBondOption :: AffineModel -> OptionType -> Double -> Double -> Maybe Double -> Double -> IO Double Source #

Analytic price of a European option on a discount bond paying 1 at bondMaturity. Nothing starts the bond at option expiry; Just supplies a distinct bond start. Only HullWhite distinguishes the two upstream overloads.

convexityBias Source #

Arguments

:: Double

futurePrice

-> Double

t

-> Double

T

-> Double

sigma

-> Double

a

-> IO Double 

Futures convexity bias (difference between futures implied rate and forward rate), per G. Kirikos, D. Novak, "Convexity Conundrums", Risk Magazine, March 1997. t/T are in yearfraction using the deposit day counter, futurePrice is the futures' market price. Not pure: convexityBias can throw (QL_REQUIRE on its inputs), and letting a C++ exception unwind across the FFI boundary from an unsafePerformIO-backed pure binding is undefined behavior, so this needs the same 'char **e/preErrorCheck' error channel as any other throwing call.

numeraire Source #

Arguments

:: Gaussian1dModel 
-> Day

referenceDate

-> Double

y

-> Maybe (GenYieldTermStructure y)

yts

-> IO Double 

Numeraire value at referenceDate, conditional on the standardized state variable y (0 = the model's expected path). yts overrides the model's own term structure for discounting when given, otherwise the model's own curve is used.

gaussian1dZerobond Source #

Arguments

:: Gaussian1dModel 
-> Day

maturity

-> Maybe Day

referenceDate

-> Double

y

-> Maybe (GenYieldTermStructure y)

yts

-> IO Double 

Price at referenceDate (default: the evaluation date) of a zero-coupon bond paying 1 at maturity, conditional on the standardized state variable y (0 = the model's expected path). yts overrides the model's own term structure for discounting when given.

gaussian1dZerobondOption Source #

Arguments

:: Gaussian1dModel 
-> OptionType

type

-> Day

expiry

-> Day

valueDate

-> Day

maturity

-> Double

strike

-> Maybe Day

referenceDate

-> Double

y

-> Maybe (GenYieldTermStructure y)

yts

-> Double

yStdDevs

-> Word

yGridPoints

-> Bool

extrapolatePayoff

-> Bool

flatPayoffExtrapolation

-> IO Double 

Price of a European option of type, expiring at expiry with strike, on a zero-coupon bond that itself pays 1 at maturity and settles at valueDate, conditional on the standardized state variable y at referenceDate (default: the evaluation date). yts overrides the model's own discounting curve when given. The option payoff is evaluated on a grid of yGridPoints points spanning yStdDevs standard deviations of y; extrapolatePayoff/flatPayoffExtrapolation control payoff extrapolation beyond the grid.

gaussian1dCompoundedRate Source #

Arguments

:: Gaussian1dModel

model

-> OvernightIndexedCoupon

coupon

-> Maybe Day

referenceDate

-> Double

y

-> Maybe (GenYieldTermStructure y)

curve

-> IO Double 

Conditional compounded overnight rate using the coupon's observation dates and index day counter; ignores gearing/spread and historical fixings. Requires QuantLib 1.44. Nothing selects the model reference date or model curve.

gaussian1dForwardRate Source #

Arguments

:: Gaussian1dModel 
-> Day

fixing

-> Maybe Day

referenceDate

-> Double

y

-> Maybe (GenIborIndex ibor)

iborIdx

-> IO Double 

Forward rate for iborIdx fixing on fixing, conditional on the standardized state variable y at referenceDate (default: the evaluation date). iborIdx defaults to the model's own term structure's natural index when omitted.

gaussian1dSwapRate Source #

Arguments

:: Gaussian1dModel 
-> Day

fixing

-> (Int, TimeUnit)

tenor

-> Maybe Day

referenceDate

-> Double

y

-> Maybe (GenSwapIndex sidx)

swapIdx

-> IO Double 

Fair swap rate for a swap on swapIdx fixing on fixing with tenor tenor, conditional on the standardized state variable y at referenceDate (default: the evaluation date).

gaussian1dSwapAnnuity Source #

Arguments

:: Gaussian1dModel 
-> Day

fixing

-> (Int, TimeUnit)

tenor

-> Maybe Day

referenceDate

-> Double

y

-> Maybe (GenSwapIndex sidx)

swapIdx

-> IO Double 

Annuity (present value of a 1bp fixed leg) of a swap on swapIdx fixing on fixing with tenor tenor, conditional on the standardized state variable y at referenceDate (default: the evaluation date).

gaussian1dYGrid Source #

Arguments

:: Gaussian1dModel 
-> Double

yStdDevs

-> Int

gridPoints

-> Double

bigT

-> Double

t

-> Double

y

-> IO RealVector 

Grid of values for the standardized state variable at time T, conditional on the variable being y at time t, spanning yStdDevs standard deviations with 2*gridPoints+1 points.

lfmHullWhiteCovariance :: LfmHullWhiteParameterization -> Double -> [Double] -> IO (Matrix Double) Source #

Instantaneous covariance matrix at t for the supplied forward-rate state x.

liborForwardModelS0 Source #

Arguments

:: LiborForwardModel 
-> Word

alpha

-> Word

beta

-> IO Double 

Initial value of the discrete forward rate indexed by alpha, as seen from time index beta (both indices into the process's tenor structure): the model's calibration input S_0(alpha,beta).

blackPrice Source #

Arguments

:: GenBlackCalibrationHelper bch 
-> Double

volatility

-> IO Double 

Black price given a volatility.

impliedVolatility Source #

Arguments

:: GenBlackCalibrationHelper bch 
-> Double

targetValue

-> Double

accuracy

-> Word

maxEvaluations

-> Double

minVol

-> Double

maxVol

-> IO Double 

Black volatility implied by the model.

Model state and calibration

roughHestonTheta Source #

Arguments

:: RoughHestonModel

model

-> IO Double 

Current calibrated theta (1.44).

roughHestonKappa Source #

Arguments

:: RoughHestonModel

model

-> IO Double 

Current calibrated kappa (1.44).

roughHestonSigma Source #

Arguments

:: RoughHestonModel

model

-> IO Double 

Current calibrated sigma (1.44).

roughHestonRho Source #

Arguments

:: RoughHestonModel

model

-> IO Double 

Current calibrated rho (1.44).

roughHestonV0 Source #

Arguments

:: RoughHestonModel

model

-> IO Double 

Current calibrated v0 (1.44).

roughHestonHurst Source #

Arguments

:: RoughHestonModel

model

-> IO Double 

Current calibrated hurst (1.44).

roughHestonProcess Source #

Arguments

:: RoughHestonModel

model

-> IO HestonProcess 

Current calibrated process (1.44).

class HasLeverageFunction a where Source #

Models that expose a calibrated local-volatility leverage function.

class HasVolatilities a where Source #

Models that expose their calibrated volatility step values.

Methods

volatilities :: a -> IO [Double] Source #

Instances

Instances details
HasVolatilities Gsr Source # 
Instance details

Defined in QuantLib.Model

Methods

volatilities :: Gsr -> IO [Double] Source #

HasVolatilities MarkovFunctional Source # 
Instance details

Defined in QuantLib.Model

reversions :: Gsr -> IO [Double] Source #

Reversion values, as calibrated so far: one for a constant reversion, otherwise one per volatility step.

class HasHelperUnderlying h where Source #

Bootstrap and calibration helpers that build and hold the instrument whose market quote they match. The class lives here, in the term-structure root module, because its instances span QuantLib.TermStructure.Yield, ".Inflation" and QuantLib.Model, and an instance must share a module with its class to stay non-orphan.

Associated Types

type HelperUnderlying h Source #

Methods

helperInstrument :: h -> IO (HelperUnderlying h) Source #

The instrument the helper prices. For helpers that build it internally -- fixedRateBondHelper and cpiBondHelper among them -- this is the only way to reach it.

Instances

Instances details
HasHelperUnderlying BondHelper Source # 
Instance details

Defined in QuantLib.TermStructure

Associated Types

type HelperUnderlying BondHelper 
Instance details

Defined in QuantLib.TermStructure

HasHelperUnderlying OISRateHelper Source # 
Instance details

Defined in QuantLib.TermStructure

HasHelperUnderlying SwapRateHelper Source # 
Instance details

Defined in QuantLib.TermStructure

Associated Types

type HelperUnderlying SwapRateHelper 
Instance details

Defined in QuantLib.TermStructure

HasHelperUnderlying SwaptionHelper Source # 
Instance details

Defined in QuantLib.TermStructure

HasHelperUnderlying YearOnYearInflationSwapHelper Source # 
Instance details

Defined in QuantLib.TermStructure

HasHelperUnderlying ZeroCouponInflationSwapHelper Source # 
Instance details

Defined in QuantLib.TermStructure

g2Dynamics :: G2 -> IO ShortRateDynamics Source #

The two-factor short-rate dynamics underlying a G2 model (TwoFactorModel::dynamics()).

shortRate Source #

Arguments

:: ShortRateDynamics 
-> Double

t

-> Double

x

-> Double

y

-> IO Double 

Short rate implied by a ShortRateDynamics's two state variables x, y at time t: fitting_(t) + x + y. At x = y = 0 this collapses to the model's fitting parameter phi(t).

stateProcess :: Gaussian1dModel -> IO StochasticProcess1D Source #

The model's own state process. Throws if the model was constructed without one set.

hestonSlvFdmLogEntries :: HestonSLVFDMModel -> IO [HestonSLVFDMLogEntry] Source #

Copies retained FDM density diagnostics. Returns [] when the model was built with logging = False. Calling this makes one fresh QuantLib diagnostic calculation, then decodes its owned snapshot without retaining the model's mesh objects.

helperSwaption :: SwaptionHelper -> IO Swaption Source #

The Swaption this helper prices internally to compute modelValue.

times :: GenBlackCalibrationHelper bch -> IO [Double] Source #

Times relevant to pricing this calibration helper's instrument, to be added to the model's evolution time grid.

fixedReversion :: [Bool] Source #

Marks the reversion (a) fixed and volatility (sigma) free for calibrate's fixParameters argument. Mirrors HullWhite::FixedReversion().

params :: GenCalibratedModel m -> IO [Double] Source #

Returns array of arguments on which calibration is done.

value :: GenCalibratedModel m -> [Double] -> [GenCalibrationHelper ch] -> IO Double Source #

Objective function value at params for the given calibration instruments.

calibrationError :: GenBlackCalibrationHelper bch -> IO Double Source #

returns the error resulting from the model valuation

marketValue :: GenBlackCalibrationHelper bch -> IO Double Source #

returns the actual price of the instrument (from volatility)

modelValue :: GenBlackCalibrationHelper bch -> IO Double Source #

returns the price of the instrument according to the model

volatility :: GenBlackCalibrationHelper bch -> IO Quote Source #

The quoted market volatility this helper was built with.

Historical volatility

forecast Source #

Arguments

:: Garch11 
-> Double

r

-> Double

sigma2

-> Double 

one-step-ahead variance forecast: gamma*vl + alpha*r^2 + beta*sigma2, given the latest return r and the previous step's variance sigma2.

calculate Source #

Arguments

:: Garch11 
-> NonEmpty (Day, Double)

return series

-> IO [(Day, Double)] 

Runs the model's calibrated (or constructor-supplied) alpha/beta/omega recursion forward over a return series. The output series is offset by one from the input: the first input point has nothing to forecast from, so it is dropped, and one extra point is extrapolated one step past the input series' last date -- an n-point input still produces an n-point output, just shifted forward by one date.

garmanKlassSimpleSigma Source #

Arguments

:: Double

yearFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Garman-Klass (1980) simple estimator: sigma^2 = ln(close/open)^2, scaled by yearFraction. Input bars are (date, open, close, high, low); only open/close are used here.

garmanKlassSigma1 Source #

Arguments

:: Double

yearFraction

-> Double

marketOpenFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Garman-Klass Sigma1: blends garmanKlassSimpleSigma with the overnight (previous close to today's open) jump, weighted by marketOpenFraction (the fraction of the trading day the market is open). Drops the series' first bar (needs a previous close).

parkinsonSigma Source #

Arguments

:: Double

yearFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Parkinson (1980) high-low estimator: sigma^2 = ln(high/low)^2 / (4 ln 2), scaled by yearFraction. Input bars are (date, open, close, high, low); only high/low are used here.

garmanKlassSigma3 Source #

Arguments

:: Double

yearFraction

-> Double

marketOpenFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Garman-Klass Sigma3: blends parkinsonSigma with the overnight jump, same marketOpenFraction weighting as garmanKlassSigma1. Drops the series' first bar.

garmanKlassSigma4 Source #

Arguments

:: Double

yearFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Garman-Klass (1980) Sigma4 estimator, combining the high-low range with the close-open return via their published coefficients. Input bars are (date, open, close, high, low).

garmanKlassSigma5 Source #

Arguments

:: Double

yearFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Garman-Klass (1980) Sigma5 estimator: an alternative high-low/close-open combination to garmanKlassSigma4, with different published coefficients.

garmanKlassSigma6 Source #

Arguments

:: Double

yearFraction

-> Double

marketOpenFraction

-> NonEmpty (Day, Double, Double, Double, Double)

(date, open, close, high, low) price bars

-> IO [(Day, Double)] 

Garman-Klass Sigma6: blends garmanKlassSigma5 with the overnight jump, same marketOpenFraction weighting as garmanKlassSigma1. Drops the series' first bar.

constantVolatilityEstimator Source #

Arguments

:: Word

windowSize

-> NonEmpty (Day, Double)

volatility series

-> IO [(Day, Double)] 

Smooths an already-computed volatility series with a rolling constant estimate over the trailing windowSize points.

simpleLocalVolatilityEstimator Source #

Arguments

:: Double

yearFraction

-> NonEmpty (Day, Double)

price series

-> IO [(Day, Double)] 

Local (point-to-point) volatility estimate from a raw price series: |ln(p_i/p_{i-1})| / sqrt(yearFraction) for each consecutive pair. Drops the series' first date; an n-point input produces an (n-1)-point output.

alpha :: Garch11 -> Double Source #

the calibrated (or constructor-supplied) alpha coefficient

beta :: Garch11 -> Double Source #

the calibrated (or constructor-supplied) beta coefficient

omega :: Garch11 -> Double Source #

the calibrated (or derived) omega coefficient, vl * (1 - alpha - beta)

longTermVolatility :: Garch11 -> Double Source #

the calibrated (or constructor-supplied) long-term volatility

logLikelihood :: Garch11 -> Double Source #

the log-likelihood of the calibrated fit; 0 for a direct-parameter (garch11) model