Models Functions

In this section we document models for various risk factors.

Data Structures and Constructors

DiffFusion.ModelType
abstract type Model end

An abstract base model type. This type covers component models and hybrid composite models.

DiffFusion.ComponentModelType
abstract type ComponentModel <: Model end

An abstract component model type. This type implements the common interface of all component models.

DiffFusion.AssetModelType
abstract type AssetModel <: ComponentModel end

An AssetModel aims at modelling spot prices of tradeable assets like FX, shares and indices.

We implement several additional functions to handle quanto adjustments.

DiffFusion.LognormalAssetModelType
struct LognormalAssetModel <: AssetModel
    alias::String
    sigma_x::BackwardFlatVolatility
    state_alias::AbstractVector
    factor_alias::AbstractVector
    correlation_holder::CorrelationHolder
    quanto_model::Union{AssetModel, Nothing}
end

A LognormalAssetModel is a model for simulating a spot price in a generalised Black-Scholes framework.

DiffFusion.lognormal_asset_modelFunction
lognormal_asset_model(
    alias::String,
    sigma_x::BackwardFlatVolatility,
    ch::CorrelationHolder,
    quanto_model::Union{AssetModel, Nothing}
    )

Create a LognormalAssetModel.

lognormal_asset_model(
    alias::String,
    dom_model::Union{GaussianHjmModel, Nothing},
    for_model::Union{GaussianHjmModel, Nothing},
    ch::Union{CorrelationHolder, Nothing},
    option_times::AbstractVector,
    asset_volatilities::AbstractVector,
    )

Calibrate an asset model to implied lognormal volatilities.

DiffFusion.SeparableHjmModelType
abstract type SeparableHjmModel <: ComponentModel end

An abstract type for separable HJM models.

This type covers common functions for Gaussian and Quasi-Gaussian models.

The SeparableHjmModel is supposed to hold a constant vector-valued ParameterTermstructure for mean reversion chi and benchmark rate times delta.

DiffFusion.GaussianHjmModelType
struct GaussianHjmModel <: SeparableHjmModel
    alias::String
    delta::ParameterTermstructure
    chi::ParameterTermstructure
    sigma_T::GaussianHjmModelVolatility
    y::AbstractArray
    state_alias::AbstractVector
    factor_alias::AbstractVector
    correlation_holder::Union{CorrelationHolder, Nothing}
    quanto_model::Union{AssetModel, Nothing}
end

A Gaussian HJM model with piece-wise constant benchmark rate volatility and constant mean reversion.

DiffFusion.gaussian_hjm_modelMethod
gaussian_hjm_model(
    alias::String,
    delta::ParameterTermstructure,
    chi::ParameterTermstructure,
    sigma_f::BackwardFlatVolatility,
    correlation_holder::Union{CorrelationHolder, Nothing},
    quanto_model::Union{AssetModel, Nothing},
    )

Create a Gausian HJM model.

DiffFusion.MarkovFutureModelType
struct MarkovFutureModel <: SeparableHjmModel
    hjm_model::GaussianHjmModel
end

A Markov model for Future prices with piece-wise constant benchmark price volatility and constant mean reversion.

We implement an object adapter for the GaussianHjmModel to re-use implementation for common modelling parts.

The MarkovFutureModel differs from the GaussianHjmModel essentially only by the drift Theta.

Moreover, we do not require the integrated state variable and want to identify correlations with Future prices instead of forward rates.

DiffFusion.markov_future_modelFunction
markov_future_model(
    alias::String,
    delta::ParameterTermstructure,
    chi::ParameterTermstructure,
    sigma_f::BackwardFlatVolatility,
    correlation_holder::Union{CorrelationHolder, Nothing},
    quanto_model::Union{AssetModel, Nothing},
    )

Create a Gausian Markov model for Future prices.

DiffFusion.CompositeModelType
abstract type CompositeModel <: Model

A CompositeModel represents a collection of (coupled) component models.

CompositeModels are supposed to hold the following elements

alias::String
models::Tuple
state_alias
factor_alias
model_dict::Dict{String,Int}

For concrete types, see SimpleModel.

DiffFusion.SimpleModelType
struct SimpleModel <: Model
    alias::String
    models::Tuple
    state_alias
    factor_alias
    model_dict::Dict{String,Int}
end

A SimpleModel represents a collection of (coupled) state-independent component models.

It is supposed to be used with a simple_simulation() method.

State Variable

A model allows to simulate a stochastic process $\left(X_t\right)$. For a given $t$ the vector $X_t$ is represented by a ModelState.

DiffFusion.ModelStateType
struct ModelState
    X::AbstractMatrix
    idx::Dict{String,Int}
end

A ModelState is a matrix of state variables decorated by a dictionary of alias strings and optional additional parameters.

It allows to decouple simulation of state variables and usage of state variables.

X is of size (n, p) where n represents the number of state aliases and p represents the number of paths. A matrix with a large number of paths is typically used when calling model functions for payoff evaluation.

A single realisation of risk factors is represented by an (n, 1) matrix. We use (n,1) matrix instead of (n,) vector to avoid size-dependent switches.

idx is a dictionary with n entries. Keys represent state state alias entries and values represent the corresponding positions in X.

params is a struct or dictionary that holds additional pre-calculated state-independent data which is used in subsequent Theta and Sigma calculations. This aims at avoiding duplicate calculations for state-dependent Theta and Sigma calculations. The params is supposed to be calculated by method simulation_parameters(...).

DiffFusion.model_stateFunction
model_state(X::AbstractMatrix, idx::Dict{String,Int})

Create a ModelState object and make sure it is consistent.

model_state(X::AbstractMatrix, m::Model, params = nothing)

Create a model state for a given model.

Auxilliary Methods

DiffFusion.aliasMethod
alias(m::Model)

Return the model's own alias. This is the default implementation.

DiffFusion.model_aliasFunction
model_alias(m::Model)

Return the aliases modelled by a model.

Typically, this coincides with the model's own alias. For composite models this is a list of component model aliases.

model_alias(m::CompositeModel)

Return the aliases modelled by a model.

Typical this coincides with the model's own alias. For composite models this is a list of component model aliases.

DiffFusion.state_aliasFunction
state_alias(m::Model)

Return a list of state alias strings that represent the model components.

DiffFusion.factor_aliasFunction
factor_alias(m::Model)

Return a list of risk factor alias strings that represent the components of the multi-variate Brownian motion risk factors.

DiffFusion.parameter_gridFunction
parameter_grid(m::Model)

Return a list of times representing the (joint) grid points of piece-wise constant model parameters.

This method is intended to be used in conjunction with time-integration mehods that require smooth integrand functions.

parameter_grid(models::AbstractVector)

Return a list of times representing the (joint) grid points of piece-wise constant model parameters.

This method is intended to be used in conjunction with time-integration mehods that require smooth integrand functions.

parameter_grid(m::LognormalAssetModel)

Return a list of times representing the (joint) grid points of piece-wise constant model parameters.

This method is intended to be used in conjunction with time-integration mehods that require smooth integrand functions.

parameter_grid(m::CompositeModel)

Return a list of times representing the (joint) grid points of piece-wise constant model parameters.

This method is intended to be used in conjunction with time-integration mehods that require smooth integrand functions.

parameter_grid(m::GaussianHjmModel)

Return a list of times representing the (joint) grid points of piece-wise constant model parameters.

This method is intended to be used in conjunction with time-integration mehods that require smooth integrand functions.

parameter_grid(m::MarkovFutureModel)

Return a list of times representing the (joint) grid points of piece-wise constant model parameters.

This method is intended to be used in conjunction with time-integration mehods that require smooth integrand functions.

Model Functions for Payoff Evaluation

DiffFusion.log_assetFunction
log_asset(m::Model, alias::String, t::ModelTime, X::ModelState)

Retrieve the normalised state variable from an asset model.

Returns a vector of size (p,) for X with size (n,p).

log_asset(m::LognormalAssetModel, model_alias::String, t::ModelTime, X::ModelState)

Retrieve the normalised state variable from an asset model.

log_asset(m::CompositeModel, alias::String, t::ModelTime, X::ModelState)

Retrieve the normalised state variable from an asset model.

DiffFusion.log_bank_accountFunction
log_bank_account(m::Model, alias::String, t::ModelTime, X::ModelState)

Retrieve the integral over sum of state variables s(t) from interest rate model.

Returns a vector of size (p,) for X with size (n,p).

log_bank_account(m::CompositeModel, alias::String, t::ModelTime, X::ModelState)

Retrieve the integral over sum of state variables s(t) from interest rate model.

log_bank_account(m::GaussianHjmModel, model_alias::String, t::ModelTime, X::ModelState)

Retrieve the integral over sum of state variables s(t) from interest rate model.

DiffFusion.log_zero_bondFunction
log_zero_bond(m::Model, alias::String, t::ModelTime, T::ModelTime, X::ModelState)

Calculate the zero bond term [G(t,T)' x(t) + 0.5 G(t,T)' y(t) G(t,T)]' from rates model.

Returns a vector of size (p,) for X with size (n,p).

log_zero_bond(m::CompositeModel, alias::String, t::ModelTime, T::ModelTime, X::ModelState)

Calculate the zero bond term [G(t,T)' x(t) + 0.5 G(t,T)' y(t) G(t,T)]' from rates model.

log_zero_bond(m::GaussianHjmModel, model_alias::String, t::ModelTime, T::ModelTime, X::ModelState)

Calculate the zero bond term [G(t,T)' x(t) + 0.5 G(t,T)' y(t) G(t,T)]' from rates model.

DiffFusion.log_zero_bondsFunction
log_zero_bonds(m::Model, alias::String, t::ModelTime, T::AbstractVector, X::ModelState)

Calculate the zero bond terms [G(t,T)' x(t) + 0.5 G(t,T)' y(t) G(t,T)]' from rates model.

log_zero_bonds(m::CompositeModel, alias::String, t::ModelTime, T::AbstractVector, X::ModelState)

Calculate the zero bond terms [G(t,T)' x(t) + 0.5 G(t,T)' y(t) G(t,T)]' from rates model.

log_zero_bonds(m::GaussianHjmModel, model_alias::String, t::ModelTime, T::AbstractVector, X::ModelState)

Calculate the zero bond terms [G(t,T)' x(t) + 0.5 G(t,T)' y(t) G(t,T)]' from rates model.

DiffFusion.log_compounding_factorFunction
log_compounding_factor(
    m::Model,
    model_alias::String,
    t::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    X::ModelState,
    )

Calculate the forward compounding factor term [G(t,T2) - G(t,T1)]' x(t) + 0.5 * [G(t,T2)' y(t) G(t,T2) - G(t,T1)' y(t) G(t,T1)].

This is used for Libor forward rate calculation.

Returns a vector of size (p,) for X with size (n,p).

log_compounding_factor(
    m::CompositeModel,
    alias::String,
    t::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    X::ModelState,
    )

Calculate the forward compounding factor term [G(t,T2) - G(t,T1)]' x(t) + 0.5 * [G(t,T2)' y(t) G(t,T2) - G(t,T1)' y(t) G(t,T1)].

This is used for Libor forward rate calculation.

Returns a vector of size (p,) for X with size (n,p).

log_compounding_factor(
    m::GaussianHjmModel,
    model_alias::String,
    t::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    X::ModelState,
    )

Calculate the forward compounding factor term [G(t,T2) - G(t,T1)]' x(t) + 0.5 * [G(t,T2)' y(t) G(t,T2) - G(t,T1)' y(t) G(t,T1)].

This is used for Libor forward rate calculation.

DiffFusion.log_asset_convexity_adjustmentFunction
log_asset_convexity_adjustment(
    m::Model,
    dom_alias::String,
    for_alias::String,
    ast_alias::String,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    )

Calculate the YoY convexity adjustment term for OU models.

Returns a scalar quantity.

log_asset_convexity_adjustment(
    m::CompositeModel,
    dom_alias::String,
    for_alias::String,
    ast_alias::String,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    )

Calculate the YoY convexity adjustment term for OU models.

Returns a scalar quantity.

log_asset_convexity_adjustment(
    dom_model::GaussianHjmModel,
    for_model::GaussianHjmModel,
    ast_model::LognormalAssetModel,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    )

Calculate convexity adjustment for year-on-year coupons of tradeable assets.

DiffFusion.log_futureFunction
log_future(m::Model, alias::String, t::ModelTime, T::ModelTime, X::ModelState)

Calculate the Future price term h(t,T)'[x(t) + 0.5y(t)(1 - h(t,T))].

log_future(m::CompositeModel, alias::String, t::ModelTime, T::ModelTime, X::ModelState)

Calculate the Future price term h(t,T)'[x(t) + 0.5y(t)(1 - h(t,T))].

log_future(m::MarkovFutureModel, alias::String, t::ModelTime, T::ModelTime, X::ModelState)

Calculate the Future price term (h(t,T)'[x(t) + 0.5y(t)(1 - h(t,T))])'.

DiffFusion.forward_rate_varianceFunction
forward_rate_variance(
    m::Model,
    alias::String,
    t::ModelTime,
    T::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    )

Calculate the lognormal variance for a compounding factor of a forward-looking or backward-looking forward rate.

forward_rate_variance(
    m::CompositeModel,
    alias::String,
    t::ModelTime,
    T::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    )

Calculate the lognormal variance for a compounding factor of a forward-looking or backward-looking forward rate.

forward_rate_variance(
    m::GaussianHjmModel,
    t::ModelTime,
    T::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    )

Calculate the lognormal variance for a compounding factor of a forward-looking or backward-looking forward rate.

Time t is the observation time, T is the rate fixing time or option exercise time, T0 is the rate period start time, and T1 is the rate period end time.

If t ≤ T0 then we calculate the variance for a forward-looking rate. If t = T1 then we calculate the variance for a backward-looking rate.

forward_rate_variance(
    m::GaussianHjmModel,
    alias::String,
    t::ModelTime,
    T::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    )

Calculate the lognormal variance for a compounding factor of a forward-looking or backward-looking forward rate.

This function implements the Model interface function.

forward_rate_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
T0::ModelTime,
T1::ModelTime,
key::String,
)

Calculate the lognormal variance for a compounding factor of a forward-looking or backward-looking forward rate.

forward_rate_variance(
p::Path,
t::ModelTime,
T::ModelTime,
T0::ModelTime,
T1::ModelTime,
key::String,
)

Calculate the lognormal variance for a compounding factor of a forward-looking or backward-looking forward rate.

DiffFusion.swap_rate_varianceFunction
swap_rate_variance(
    m::Model,
    alias::String,
    yts::YieldTermstructure,
    t::ModelTime,
    T::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    X::ModelState,
    )

Calculate the normal model variance of a swap rate via Gaussian swap rate approximation.

swap_rate_variance(
    m::CompositeModel,
    alias::String,
    yts::YieldTermstructure,
    t::ModelTime,
    T::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    X::ModelState,
    )

Calculate the normal model variance of a swap rate via Gaussian swap rate approximation.

swap_rate_variance(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    T::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    SX::ModelState,
    )

Calculate the normal model variance of a swap rate via Gaussian swap rate approximation.

Observation time is t, Option expiry time is T.

See method swap_rate_gradient for details on further input parameters.

swap_rate_variance(
    m::GaussianHjmModel,
    alias::String,
    yts::YieldTermstructure,
    t::ModelTime,
    T::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    X::ModelState,
    )

Calculate the normal model variance of a swap rate via Gaussian swap rate approximation.

This function is implements the Model interface function.

See method swap_rate_gradient for details on further input parameters.

swap_rate_variance(
    p::AbstractPath,
    t::ModelTime,
    T::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    key::String,
    )

Calculate the normal model variance of a swap rate via Gaussian swap rate approximation.

swap_rate_variance(
    p::Path,
    t::ModelTime,
    T::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    key::String,
    )

Calculate the normal model variance of a swap rate via Gaussian swap rate approximation.

Model Functions for Simulation

DiffFusion.ThetaFunction
Theta(
    m::Model,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the deterministic drift component for simulation over the time period [s, t]. If Theta is state-dependent a state vector X must be supplied. The method returns a vector of length(state_alias).

Theta(
    m::LognormalAssetModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the deterministic drift component for simulation over the time period [s, t].

Theta(
    m::SimpleModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the deterministic drift component for simulation over the time period [s, t].

Theta(
    m::GaussianHjmModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the deterministic drift component for simulation over the time period [s, t]. If Theta is state-dependent a state vector X must be supplied. The method returns a vector of length(state_alias).

Theta(
    m::MarkovFutureModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the deterministic drift component for simulation over the time period [s, t]. If Theta is state-dependent a state vector X must be supplied. The method returns a vector of length(state_alias).

DiffFusion.H_TFunction
H_T(
    m::Model,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the transposed of the convection matrix H for simulation over the time period [s, t]. If H is state-dependent a state vector X must be supplied. We use the transposed of H to

  • allow for efficient sparse CSC matrix insertion and
  • allow for efficient multiplication X' * H' = (H * X)'.

The state vector X may effectively be a subset of all states. To accommodate this, we use a dedicated list of state aliases state_alias_H for the result matrix. The method returns a (sparse) matrix of size (length(state_alias_H), length(state_alias)).

H_T(
    m::LognormalAssetModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the transposed of the convection matrix H for simulation over the time period [s, t].

H_T(
    m::SimpleModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the transposed of the convection matrix H for simulation over the time period [s, t].

H_T(
    m::GaussianHjmModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the transposed of the convection matrix H for simulation over the time period [s, t].

H_T(
    m::MarkovFutureModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return the transposed of the convection matrix H for simulation over the time period [s, t].

DiffFusion.Sigma_TFunction
Sigma_T(
    m::Model,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a matrix-valued function representing the volatility matrix function.

The signature of the resulting function is (u::ModelTime). Here, u represents the observation time.

The state vector is required if Sigma(u) depends on X_s.

The result of an evaluation of Sigma_T(...)(u) is a matrix of size (length(state_alias), length(factor_alias_Sigma)).

The Brownian motion relevant for a model may effectively be a subset of all Brownian motions. To accommodate this, we use a dedicated list of factor aliases factor_alias_Sigma for the size of the result matrix of a function evaluation.

The transposed '_T' is convention to simplify notation for covariance calculation.

Sigma_T(
    m::LognormalAssetModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a matrix-valued function representing the volatility matrix function.

The signature of the resulting function is (u::ModelTime). Here, u represents the observation time.

Sigma_T(
    m::SimpleModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a matrix-valued function representing the volatility matrix function.

The signature of the resulting function is (u::ModelTime). Here, u represents the observation time.

Sigma_T(
    m::GaussianHjmModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a matrix-valued function representing the volatility matrix function.

Sigma_T(
    m::MarkovFutureModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a matrix-valued function representing the volatility matrix function.

DiffFusion.state_dependent_ThetaFunction
state_dependent_Theta(m::Model)

Return whether Theta requires a state vector input X.

state_dependent_Theta(m::LognormalAssetModel)

Return whether Theta requires a state vector input X.

state_dependent_Theta(m::CompositeModel)

Return whether Theta requires a state vector input X.

state_dependent_Theta(m::GaussianHjmModel)

Return whether Theta requires a state vector input X.

state_dependent_Theta(m::MarkovFutureModel)

Return whether Theta requires a state vector input X.

DiffFusion.state_dependent_HFunction
state_dependent_H(m::Model)

Return whether H requires a state vector input X.

state_dependent_H(m::LognormalAssetModel)

Return whether H requires a state vector input X.

state_dependent_H(m::CompositeModel)

Return whether H requires a state vector input X.

state_dependent_H(m::GaussianHjmModel)

Return whether H requires a state vector input X.

state_dependent_H(m::MarkovFutureModel)

Return whether H requires a state vector input X.

DiffFusion.state_dependent_SigmaFunction
state_dependent_Sigma(m::Model)

Return whether Sigma requires a state vector input X.

state_dependent_Sigma(m::LognormalAssetModel)

Return whether Sigma requires a state vector input X.

state_dependent_Sigma(m::CompositeModel)

Return whether Sigma requires a state vector input X.

state_dependent_Sigma(m::GaussianHjmModel)

Return whether Sigma requires a state vector input X.

state_dependent_Sigma(m::MarkovFutureModel)

Return whether Sigma requires a state vector input X.

DiffFusion.state_alias_HFunction
state_alias_H(m::Model)

Return a list of state alias strings required for (H * X) calculation.

state_alias_H(m::LognormalAssetModel)

Return a list of state alias strings required for (H * X) calculation.

state_alias_H(m::CompositeModel)

Return a list of state alias strings required for (H * X) calculation.

state_alias_H(m::GaussianHjmModel)

Return a list of state alias strings required for (H * X) calculation.

state_alias_H(m::MarkovFutureModel)

Return a list of state alias strings required for (H * X) calculation.

DiffFusion.factor_alias_SigmaFunction
factor_alias_Sigma(m::Model)

Return a list of factor alias strings required for (Sigma(u)' Gamma Sigma(u)) calculation.

factor_alias_Sigma(m::LognormalAssetModel)

Return a list of factor alias strings required for (Sigma(u)^T Gamma Sigma(u)) calculation.

factor_alias_Sigma(m::CompositeModel)

Return a list of factor alias strings required for (Sigma(u)^T Gamma Sigma(u)) calculation.

factor_alias_Sigma(m::GaussianHjmModel)

Return a list of factor alias strings required for (Sigma(u)^T Gamma Sigma(u)) calculation.

factor_alias_Sigma(m::MarkovFutureModel)

Return a list of factor alias strings required for (Sigma(u)^T Gamma Sigma(u)) calculation.

DiffFusion.covarianceFunction
covariance(
    m::Model,
    ch::Union{CorrelationHolder, Nothing},
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Calculate the covariance matrix over a time interval.

DiffFusion.volatility_and_correlationFunction
volatility_and_correlation(
    m::Model,
    ch::Union{CorrelationHolder, Nothing},
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    vol_eps::ModelValue = 1.0e-8,  # avoid division by zero
    )

Calculate the volatility vector and correlation matrix over a time interval.

DiffFusion.simulation_parametersFunction
simulation_parameters(
    m::Model,
    ch::Union{CorrelationHolder, Nothing},
    s::ModelTime,
    t::ModelTime,
    )

Pre-calculate parameters that are used in state-dependent Theta and Sigma calculation.

simulation_parameters(
    m::GaussianHjmModel,
    ch::Union{CorrelationHolder, Nothing},
    s::ModelTime,
    t::ModelTime,
    )

Pre-calculate parameters that are used in state-dependent Theta and Sigma calculation.

For LognormalAssetModel there are no valuations that should be cached.

simulation_parameters(
    m::GaussianHjmModel,
    ch::Union{CorrelationHolder, Nothing},
    s::ModelTime,
    t::ModelTime,
    )

Pre-calculate parameters that are used in state-dependent Theta and Sigma calculation.

For GaussianHjmModel there are no valuations that should be cached.

DiffFusion.diagonal_volatilityFunction
diagonal_volatility(
    m::Model,
    s::ModelTime,
    t::ModelTime,
    X::ModelState,
    )

Calculate the path-dependent volatilities for a given model.

X is supposed to hold a state matrix of size (n, p). Here, n is length(state_alias(m)) and p is the number of paths.

The method returns a matrix of size (n, p).

Additional Asset Model Functions

DiffFusion.asset_volatilityFunction
asset_volatility(
    m::AssetModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a state-independent volatility function sigma(u) for the interval (s,t).

asset_volatility(
    m::LognormalAssetModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a state-independent volatility function sigma(u) for the interval (s,t).

DiffFusion.quanto_driftFunction
quanto_drift(
    dom_factor_alias::AbstractVector,
    quanto_model::Nothing,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a zero quanto adjustment function alpha(u).

quanto_drift(
    dom_factor_alias::AbstractVector,
    quanto_model::AssetModel,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Return a function alpha(u) that allows to calculate the quanto adjustment on the time interval (s,t).

DiffFusion.asset_varianceFunction
asset_variance(
    m::Model,
    ast_alias::Union{String, Nothing},
    dom_alias::Union{String, Nothing},
    for_alias::Union{String, Nothing},
    t::ModelTime,
    T::ModelTime,
    X::ModelState,
    )

Calculate the lognormal model variance of an asset spot price over the time period [t,T]. If Model is state-dependent then variance calculation takes into account model state X.

asset_variance(
    m::CompositeModel,
    ast_alias::Union{String, Nothing},
    dom_alias::Union{String, Nothing},
    for_alias::Union{String, Nothing},
    t::ModelTime,
    T::ModelTime,
    X::ModelState,
    )

Calculate the lognormal model variance of an asset spot price over the time period [t,T].

asset_variance(
    ast_model::LognormalAssetModel,
    dom_model::Union{GaussianHjmModel, Nothing},
    for_model::Union{GaussianHjmModel, Nothing},
    ch::CorrelationHolder,
    s::ModelTime,
    t::ModelTime,
    X::Union{ModelState, Nothing} = nothing,
    )

Calculate lognormal variance in hybrid asset model.

The method is defined for a LognormalAssetModel. It should also work for other asset models. But then we need to calculate a vector and this requires more testing.

asset_variance(
    p::AbstractPath,
    t::ModelTime,
    T::ModelTime,
    key::String,
    )

Calculate the lognormal model variance of an asset spot price over the time period [t,T].

asset_variance(
    p::Path,
    t::ModelTime,
    T::ModelTime,
    key::String,
    )

Calculate the lognormal model variance of an asset spot price over the time period [t,T].