Additional Rates Model Functions

Model Functions for Simulation

DiffFusion.func_yFunction
func_y(
    y0::AbstractMatrix,
    chi::AbstractVector,
    sigmaT::AbstractMatrix,
    s::ModelTime,
    t::ModelTime,
    )

Calculate variance/auxiliary state variable $y(t)$ given $y(s)=y_0$.

In this function we assume that sigma is constant over the time interval $(s,t)$.

func_y(m::GaussianHjmModel, t::ModelTime)

Calculate variance/auxiliary state variable y(t).

DiffFusion.chi_hjmFunction
chi_hjm(m::SeparableHjmModel)

Return vector of constant mean reversion rates.

chi_hjm(m::MarkovFutureModel)

Return vector of constant mean reversion rates.

DiffFusion.benchmark_timesFunction
benchmark_times(m::SeparableHjmModel)

Return vector of reference/benchmark times

benchmark_times(m::MarkovFutureModel)

Return vector of reference/benchmark times

DiffFusion.H_hjmFunction
H_hjm(chi::AbstractVector, s::ModelTime, t::ModelTime)

Diagonal entries of $H(s,t)$.

H_hjm(m::SeparableHjmModel, s::ModelTime, t::ModelTime)

Diagonal entries of $H(s,t)$.

DiffFusion.G_hjmFunction
G_hjm(chi::AbstractVector, s::ModelTime, t::ModelTime)

Vector function $G(s,t)$.

G_hjm(m::SeparableHjmModel, s::ModelTime, t::ModelTime)

Vector function $G(s,t)$.

G_hjm(chi::AbstractVector, s::ModelTime, T::AbstractVector)

Vector function $G(s,t)$ as matrix of size (d,k) where k = length(T)

G_hjm(m::SeparableHjmModel, s::ModelTime, T::AbstractVector)

Vector function $G(s,t)$.

DiffFusion.benchmark_times_scalingFunction
benchmark_times_scaling(chi::AbstractVector, delta::AbstractVector)

Benchmark times volatility scaling matrix $H [H^f]^{-1} = [H^f H^{-1}]^{-1}$.

DiffFusion.func_Theta_xFunction
func_Theta_x(
    chi::AbstractVector,
    y::Function,       # (u) -> Matrix
    sigmaT::Function,  # (u) -> Matrix
    alpha::Function,   # (u) -> Vector
    s::ModelTime,
    t::ModelTime,
    param_grid::Union{AbstractVector, Nothing},
    )

Calculate Theta function for state variable x.

In this function we assume for the interval $(s,t)$ that - variance $y(s)$ is known, - volatility $σ$ is state-independent and - quanto adjustment alpha is state-independent.

DiffFusion.func_Theta_x_integrate_yFunction
func_Theta_x_integrate_y(
    chi::AbstractVector,
    y::Function,       # (u) -> Matrix
    sigmaT::Function,  # (u) -> Matrix
    alpha::Function,   # (u) -> Vector
    s::ModelTime,
    t::ModelTime,
    param_grid::Union{AbstractVector, Nothing},
    )

Calculate Theta function for state variable $x$.

Avoidance of explicit $σ^\top σ$ dependence may help with integrating over jumps in piece-wise constant volatility.

In this function we assume for the interval $(s,t)$ that - variance $y$ is state-independent, - volatility $σ$ is state-independent and - quanto adjustment $α$ is state-independent.

DiffFusion.func_Theta_sFunction
func_Theta_s(
    chi::AbstractVector,
    y::Function,       # (u) -> Matrix
    sigmaT::Function,  # (u) -> Matrix
    alpha::Function,   # (u) -> Vector
    s::ModelTime,
    t::ModelTime,
    param_grid::Union{AbstractVector, Nothing},
    )

Calculate Theta function for integrated state variable $s$.

In this function we assume for the interval $(s,t)$ that - variance $y$ state-independent, - volatility $σ$ is state-independent and - quanto adjustment $α$ is state-independent.

DiffFusion.func_ThetaFunction
func_Theta(
    chi::AbstractVector,
    y::Function,       # (u) -> Matrix
    sigmaT::Function,  # (u) -> Matrix
    alpha::Function,   # (u) -> Vector
    s::ModelTime,
    t::ModelTime,
    param_grid::Union{AbstractVector, Nothing},
    )

Calculate Theta function for component model state variable $X$.

In this function we assume for the interval $(s,t)$ that - variance $y$ state-independent, - volatility $σ$ is state-independent and - quanto adjustment $α$ is state-independent.

DiffFusion.func_H_TFunction
func_H_T(chi::AbstractVector, s::ModelTime, t::ModelTime)

Calculate $H$ function for component model.

DiffFusion.func_H_T_denseFunction
func_H_T_dense(chi::AbstractVector, s::ModelTime, t::ModelTime)

Alternative $H$ function implementation for debugging.

DiffFusion.func_Sigma_TFunction
func_Sigma_T(
    chi::AbstractVector,
    sigmaT::Function,
    s::ModelTime,
    t::ModelTime
    )

Calculate $Σ(u)^\top$ function for component model.

In this function we assume for the interval $(s,t)$ that - volatility $σ$ is state-independent.

Swap Rate Volatility Calculation

DiffFusion.GaussianHjmModelVolatilityType
struct GaussianHjmModelVolatility
    HHfInv::AbstractMatrix
    sigma_f::BackwardFlatVolatility
    DfT::AbstractMatrix
end

A dedicated matrix-valued volatility term structure for Gaussian HJM Models.

DiffFusion.swap_rate_gradientFunction
swap_rate_gradient(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    SX::ModelState,
    )

The gradient dS/dx in a Gaussian HJM model.

Returns a matrix of size (p, d). Here, p is the number of paths in SX and d is the number of factors of the GHJM model, i.e., d = length(factor_alias(m)).

Observation time is t. The swap rate is specified by swap_times and yf_weights. swap_times[begin] is the start time of the first (floating rate) coupon period. swap_times[k] for k>begin represent the pay times of the fixed leg coupons. yf_weights are the year fractions of the fixed leg coupons.

The swap rate is constructed assuming single-curve setting without tenor basis. yts is the initial (discounting) yield curve.

The swap rate gradient depends on the simulated model state at t. The model state is encoded in SX.

DiffFusion.swap_rate_instantaneous_covarianceFunction
swap_rate_instantaneous_covariance(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    swap_times_1::AbstractVector,
    yf_weights_1::AbstractVector,
    swap_times_2::AbstractVector,
    yf_weights_2::AbstractVector,
    SX::ModelState,
    )

Calculate the instantaneous covariance of two swap rates.

See method swap_rate_gradient for details on the input parameters.

DiffFusion.swap_rate_volatility²Function
swap_rate_volatility²(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    swap_times::AbstractVector,
    yf_weights::AbstractVector,
    SX::ModelState,
    )

Calculate the square of swap rate volatility (or instantaneous variance).

See method swap_rate_gradient for details on the input parameters.

DiffFusion.swap_rate_covarianceFunction
swap_rate_covariance(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    T::ModelTime,
    swap_times_1::AbstractVector,
    yf_weights_1::AbstractVector,
    swap_times_2::AbstractVector,
    yf_weights_2::AbstractVector,
    SX::ModelState,
    )

Calculate the covariance of two swap rates over the time intervall (t,T).

See method swap_rate_gradient for details on the input parameters.

DiffFusion.swap_rate_correlationFunction
swap_rate_correlation(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    T::ModelTime,
    swap_times_1::AbstractVector,
    yf_weights_1::AbstractVector,
    swap_times_2::AbstractVector,
    yf_weights_2::AbstractVector,
    SX::ModelState,
    )

Calculate the correlation of two swap rates via Gaussian swap rate approximation over the time intervall (t,T).

See method swap_rate_gradient for details on further input parameters.

DiffFusion.model_implied_volatiltiesFunction
model_implied_volatilties(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    option_times::AbstractVector,
    swap_times::AbstractMatrix,
    swap_weights::AbstractMatrix,
    SX::Union{ModelState, Nothing} = nothing
    )

Calculate model-implied swap rate volatilities in Gaussian HJM model.

option_times are the option expiry times.

swap_times is a matrix of vectors. Each element represents swap times as specified in swap_rate_gradient.

swap_weights is a matrix of vectors. Each element represents year fraction weights as specified in swap_rate_gradient.

See method swap_rate_gradient for details on further input parameters.

model_implied_volatilties(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    option_times::AbstractVector,
    swap_times::AbstractVector,
    swap_weights::AbstractVector,
    SX::Union{ModelState, Nothing} = nothing
    )

Calculate model-implied swap rate volatilities in Gaussian HJM model.

option_times are the option expiry times.

swap_times is a vector of vectors. Each element represents time offsets that are added to option_times in order to form swap_times as specified in swap_rate_gradient.

swap_weights is a vector of vectors. Each element represents year fraction weights as specified in swap_rate_gradient. swap_weights are assumed equal per expiry time.

See method swap_rate_gradient for details on further input parameters.

model_implied_volatilties(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    option_times::AbstractVector,
    swap_maturities::AbstractVector,
    SX::Union{ModelState, Nothing} = nothing
    )

Calculate model-implied swap rate volatilities in Gaussian HJM model.

option_times are the option expiry times.

swap_maturities is a list of swap tenors. Swap times and year fraction weights are calculated from swap_maturities assuming an annual schedule.

See method swap_rate_gradient for details on further input parameters.

Model Calibration

DiffFusion.gaussian_hjm_modelMethod
gaussian_hjm_model(
    alias::String,
    ch::Union{CorrelationHolder, Nothing},
    option_times::AbstractVector,
    swap_maturities::AbstractVector,
    swap_rate_volatilities::AbstractMatrix,
    yts::YieldTermstructure;
    max_iter::Integer = 5,
    volatility_regularisation::ModelValue = 0.0,
    )

Calibrate a model with flat volatilities and mean reversion to strips of co-initial normal volatilities.

DiffFusion.gaussian_hjm_modelMethod
gaussian_hjm_model(
    alias::String,
    delta::ParameterTermstructure,
    chi::ParameterTermstructure,
    ch::Union{CorrelationHolder, Nothing},
    option_times::AbstractVector,
    swap_maturities::AbstractVector,
    swap_rate_volatilities::AbstractMatrix,
    yts::YieldTermstructure;
    max_iter::Integer = 5,
    volatility_regularisation::ModelValue = 0.0,
    )

Calibrate a model with piece-wise constant volatilities to strips of co-initial normal volatilities.

Mean reversion (and correlations) are exogeneously specified.