FinanceModels.Spline API Reference
FinanceModels.Spline.AkimaFinanceModels.Spline.MonotoneConvexFinanceModels.Spline.PCHIPFinanceModels.Spline.CubicFinanceModels.Spline.LinearFinanceModels.Spline.Quadratic
Exported API
FinanceModels.Spline — Module
Spline is a module which offers various degree splines used for fitting or bootstraping curves via the fit function.
Available methods:
Spline.BSpline(n)where n is the nth order. A nth-order B-Spline is analogous to an (n-1)th order polynomial spline. That is, a 3rd/4th order BSpline is very similar to a quadratic/cubic spline respectively. BSplines are global in that a change in one point affects the entire spline (though the spline still passes through the other given points still).Spline.PolynomialSpline(n)where n is the nth order.
This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.
Convenience methods which create a Spline.BSpline object of the appropriate order:
Spline.Linear()equalsBSpline(2)Spline.Quadratic()equalsBSpline(3)Spline.Cubic()equalsBSpline(4)
Notes on Fitting:
fit(spline,quotes)will fit entire curve at once, with knots equal to the maturity points of theQuotesfit(spline, quotes, Fit.Bootstrap())will curve one knot at a time, with knots equal to the maturity points of theQuotes
Generally, the former will be preferred for performance reasons.
Examples
using FinanceModels
using BenchmarkTools
rates = [0.07, 0.16, 0.35, 0.92, 1.4, 1.74, 2.31, 2.41] ./ 100
mats = [1, 2, 3, 5, 7, 10, 20, 30]
qs = CMTYield.(rates, mats)
c = fit(Spline.Linear(), qs) # will fit entire curve at once, with knots equal to the maturity points of the `Quote`s
c = fit(Spline.Linear(), qs, Fit.Bootstrap()) # will curve one knot at a time, with knots equal to the maturity points of the `Quote`s
Unexported API
FinanceModels.Spline.Akima — Type
Spline.Akima()Akima (1970) interpolation. Local and resistant to outlier-induced oscillation: each segment depends on a few neighboring points. Produces C1-continuous curves.
Compared to PCHIP, Akima can produce slightly different shapes near inflection points. Both are local; PCHIP additionally preserves monotonicity.
FinanceModels.Spline.MonotoneConvex — Type
Spline.MonotoneConvex()Hagan-West (2006) monotone convex interpolation. Finance-aware: guarantees positive continuous forward rates (when input rates imply positive forwards) and matches discrete forward rates at knot points. Produces the best KRD locality among smooth methods.
Unlike other SplineCurve types that wrap DataInterpolations, this dispatches to Yield.MonotoneConvex which implements the Hagan-West sector-based polynomial construction.
References
- Hagan & West, "Interpolation Methods for Curve Construction", Applied Mathematical Finance (2006)
FinanceModels.Spline.PCHIP — Type
Spline.PCHIP()Piecewise Cubic Hermite Interpolating Polynomial (PCHIP). Local and monotonicity-preserving: each segment depends only on its immediate neighbors, so bumping one rate has bounded effect. Produces C1-continuous curves (continuous first derivative), giving smooth forward rates without the non-local coupling of cubic splines.
PCHIP is the default interpolation for ZeroRateCurve.
FinanceModels.Spline.Cubic — Method
Spline.Cubic()Create a cubic B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.
Returns
- A
BSplineobject representing a cubic B-spline.
Examples
julia> Spline.Cubic()
BSpline(4)FinanceModels.Spline.Linear — Method
Spline.Linear()Create a linear B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.
Returns
- A
BSplineobject representing a linear B-spline.
Examples
julia> Spline.Linear()
BSpline(2)FinanceModels.Spline.Quadratic — Method
Spline.Quadratic()Create a quadratic B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.
Returns
- A
BSplineobject representing a quadratic B-spline.
Examples
julia> Spline.Quadratic()
BSpline(3)Please open an issue if you encounter any issues or confusion with the package.