Yield Curves
Yield Term Structure Types
DiffFusion.YieldTermstructure — Type
abstract type YieldTermstructure <: Termstructure endAn abstract yield term structure that provides methods to calculate discount factors zero rates and forward rates.
DiffFusion.FlatForward — Type
struct FlatForward{T<:ModelValue} <: YieldTermstructure
alias::String
rate::T
endA constant yield term structure.
DiffFusion.flat_forward — Function
flat_forward(alias::String, rate)Create a FlatForward yield curve.
flat_forward(rate)Create a FlatForward yield curve without alias.
DiffFusion.ZeroCurve — Type
struct ZeroCurve{T<:ModelValue, InterpolationType} <: YieldTermstructure
alias::String
times::Vector{ModelTime}
values::Vector{T}
interpolation::InterpolationType
endA yield term structure based on interpolated continuous compounded zero rates.
DiffFusion.zero_curve — Function
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.LinearZeroCurve — Type
struct LinearZeroCurve{T<:ModelValue} <: YieldTermstructure
alias::String
times::Vector{ModelTime}
values::Vector{T}
endA 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_curve — Function
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.discount — Method
discount(ts::YieldTermstructure, t::ModelTime)Return the discount factor with observation time t.
DiffFusion.discount — Method
discount(ts::FlatForward, t::ModelTime)Calculate discount factor.
DiffFusion.discount — Method
discount(ts::ZeroCurve, t::ModelTime)Calculate discount factor.
DiffFusion.discount — Method
discount(ts::LinearZeroCurve, t::ModelTime)Calculate discount factor.
Zero Rate Calculation
DiffFusion.zero_rate — Method
zero_rate(ts::YieldTermstructure, t::ModelTime)Return the continuous compounded zero rate as of today with observation time t.
DiffFusion.zero_rate — Method
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_rate — Function
forward_rate(ts::YieldTermstructure, t::ModelTime, dt=1.0e-6)Return the instantaneous forward rate with observation time t.