Yield Curves

Yield Term Structure Types

DiffFusion.YieldTermstructureType
abstract type YieldTermstructure <: Termstructure end

An abstract yield term structure that provides methods to calculate discount factors zero rates and forward rates.

DiffFusion.FlatForwardType
struct FlatForward <: YieldTermstructure
    alias::String
    rate
end

A constant yield term structure.

DiffFusion.flat_forwardFunction
flat_forward(alias::String, rate)

Create a FlatForward yield curve.

flat_forward(rate)

Create a FlatForward yield curve without alias.

DiffFusion.ZeroCurveType
struct ZeroCurve <: YieldTermstructure
    alias::String
    times::AbstractVector
    values::AbstractVector
    interpolation
end

A yield term structure based on interpolated continuous compounded zero rates.

DiffFusion.zero_curveFunction
zero_curve(
    alias::String,
    times::AbstractVector,
    values::AbstractVector,
    interp_method = (x,y) -> linear_interpolation(x, y, extrapolation_bc = Line()),
    )

Create a ZeroCurve object.

zero_curve(
    times::AbstractVector,
    values::AbstractVector,
    interp_method = (x,y) -> linear_interpolation(x, y, extrapolation_bc = Line()),
    )

Create a ZeroCurve object without alias.

zero_curve(
    alias::String,
    times::AbstractVector,
    values::AbstractVector,
    method_alias::String,
    )

Create a ZeroCurve object using interpolation string.

zero_curve(
    times::AbstractVector,
    values::AbstractVector,
    method_alias::String,
    )

Create a ZeroCurve object using interpolation string.

DiffFusion.LinearZeroCurveType
struct LinearZeroCurve <: YieldTermstructure
    alias::String
    times::AbstractVector
    values::AbstractVector
end

A yield term structure based on continuous compounded zero rates with linear interpolation and flat extrapolation.

This curve aims at mitigating limitations of Zygote and ZeroCurve.

DiffFusion.linear_zero_curveFunction
linear_zero_curve(
    alias::String,
    times::AbstractVector,
    values::AbstractVector,
    )

Create a LinearZeroCurve.

linear_zero_curve(
    times::AbstractVector,
    values::AbstractVector,
    )

Create a LinearZeroCurve with empty alias.

Functions

Discount Factor Calculation

Call operator for YieldTermstructure is defined as

(ts::YieldTermstructure)(args...) = discount(ts, args...)
DiffFusion.discountMethod
discount(ts::YieldTermstructure, t::ModelTime)

Return the discount factor with observation time t.

DiffFusion.discountMethod
discount(ts::FlatForward, t::ModelTime)

Calculate discount factor.

DiffFusion.discountMethod
discount(ts::LinearZeroCurve, t::ModelTime)

Calculate discount factor.

Zero Rate Calculation

DiffFusion.zero_rateMethod
zero_rate(ts::YieldTermstructure, t::ModelTime)

Return the continuous compounded zero rate as of today with observation time t.

DiffFusion.zero_rateMethod
zero_rate(ts::YieldTermstructure, t0::ModelTime, t1::ModelTime)

Return the continuous compounded zero rate over a period t0 to t1.

Forward Rate Calculation

DiffFusion.forward_rateFunction
forward_rate(ts::YieldTermstructure, t::ModelTime, dt=1.0e-6)

Return the instantaneous forward rate with observation time t.