API Reference
Types
InterestRates.DayCountConvention — TypeThe type DayCountConvention sets the convention on how to count the number of days between dates, and also how to convert that number of days into a year fraction.
Given an initial date D1 and a final date D2, here's how the distance between D1 and D2 are mapped into a year fraction for each supported day count convention:
- Actual360 :
(D2 - D1) / 360 - Actual365 :
(D2 - D1) / 365 - Thirty360 :
(360*(year(D2)-year(D1)) + 30*(month(D2)-month(D1)) + (day(D2)-day(D1))) / 360 - BDays252 :
bdays(D1, D2) / 252, wherebdaysis the business days betweenD1andD2from BusinessDays.jl package.
InterestRates.DailyDatesRange — TypeDailyDatesRange{isascending, DayCountConvention} <: AbstractRange{Dates.Date}Represents the range of dates between startdate and enddate, using a timestep of 1 Day according to the DayCountConvention.
startdate and enddate are always ordered. If isascending is false, the iterator uses enddate as the first date in the iteration.
Constructor
DailyDatesRange(startdate::Date, _enddate::Date, conv::DayCountConvention, ascending::Bool=true)InterestRates.CompoundingType — TypeThe type CompoundingType sets the convention on how to convert a yield into an Effective Rate Factor.
Given a yield r and a maturity year fraction t, here's how each supported compounding type maps the yield to Effective Rate Factors:
- ContinuousCompounding :
exp(r*t) - SimpleCompounding :
(1+r*t) - ExponentialCompounding :
(1+r)^t
InterestRates.CurveMethod — TypeThis package provides the following curve methods.
Interpolation Methods
- Linear: provides Linear Interpolation on rates.
- FlatForward: provides Flat Forward interpolation, which is implemented as a Linear Interpolation on the log of discount factors.
- StepFunction: creates a step function around given data points.
- CubicSplineOnRates: provides natural cubic spline interpolation on rates.
- CubicSplineOnDiscountFactors: provides natural cubic spline interpolation on discount factors.
- CompositeInterpolation: provides support for different interpolation methods for: (1) extrapolation before first data point (
before_first), (2) interpolation between the first and last point (inner), (3) extrapolation after last data point (after_last).
For Interpolation Methods, the field dtm holds the number of days between date and the maturity of the observed yield, following the curve's day count convention, which must be given in advance, when creating an instance of the curve. The field zero_rates holds the yield values for each maturity provided in dtm. All yields must be anual based, and must also be given in advance, when creating the instance of the curve.
Term Structure Models
- NelsonSiegel: term structure model based on Nelson, C.R., and A.F. Siegel (1987), Parsimonious Modeling of Yield Curve, The Journal of Business, 60, 473-489.
- Svensson: term structure model based on Svensson, L.E. (1994), Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994, IMF Working Paper, WP/94/114.
For Term Structure Models, the field parameters holds the constants defined by each model, as described below. They must be given in advance, when creating the instance of the curve.
For NelsonSiegel method, the array parameters holds the following parameters from the model:
- beta1 = parameters[1]
- beta2 = parameters[2]
- beta3 = parameters[3]
- lambda = parameters[4]
For Svensson method, the array parameters hold the following parameters from the model:
- beta1 = parameters[1]
- beta2 = parameters[2]
- beta3 = parameters[3]
- beta4 = parameters[4]
- lambda1 = parameters[5]
- lambda2 = parameters[6]
Methods hierarchy
As a summary, curve methods are organized by the following hierarchy.
<<CurveMethod>><<Interpolation>><<DiscountFactorInterpolation>>CubicSplineOnDiscountFactorsFlatForward
<<RateInterpolation>>CubicSplineOnRatesLinearStepFunction
CompositeInterpolation
<<Parametric>>NelsonSiegelSvensson
InterestRates.AbstractIRCurve — TypeAbstract type for an Interest Rate curve
AbstractIRCurve API
InterestRates.curve_get_name — Functioncurve_get_name(curve::AbstractIRCurve) → StringReturns the name of the curve.
InterestRates.curve_get_dtm — Functioncurve_get_dtm(curve::AbstractIRCurve) → Vector{Int}Used for interpolation methods, returns days_to_maturity on curve's daycount convention.
InterestRates.curve_get_zero_rates — Functioncurve_get_zero_rates(curve::AbstractIRCurve) → Vector{Float64}Used for interpolation methods. Given an output result from this method, result[i] returns the yield for maturity dtm[i].
InterestRates.curve_get_model_parameters — Functioncurve_get_model_parameters(curve::AbstractIRCurve) → Vector{Float64}Used for parametric methods, returns model's constant parameters.
InterestRates.curve_get_date — Functioncurve_get_date(curve::AbstractIRCurve) → DateReturns the date when the curve is observed. All zero rate calculation will be performed based on this date.
InterestRates.curve_get_daycount — Functioncurve_get_daycount(curve::AbstractIRCurve) → DayCountConventionReturns the DayCountConvention used by the curve. See DayCountConvention.
InterestRates.curve_get_method — Functioncurve_get_method(curve::AbstractIRCurve) → CurveMethodReturns the CurveMethod used by the curve. See CurveMethod.
InterestRates.curve_get_compounding — Functioncurve_get_compounding(curve::AbstractIRCurve) → CompoundingTypeReturns the CompoundingType used by the curve. See CompoundingType.
Curve Methods
InterestRates.zero_rate — Functionzero_rate(curve, maturity)Returns the zero-coupon rate to maturity.
InterestRates.forward_rate — Functionforward_rate(curve, forward_date, maturity)Returns the forward rate from a future date forward_date to maturity.
InterestRates.discountfactor — Functiondiscountfactor(curve, maturity)
discountfactor(curve, forward_date, maturity)Returns the discount factor to maturity. Or a forward discount factor from forward_date to maturity.