Expand description
Yield curve interpolation and parametric fitting for fixed income.
Zero-dependency library. All curves accept (t_years, rate) pairs and
expose a uniform interface via YieldCurveInterpolator.
§Methods
LinearCurve— piecewise linear, transparent baseline.CubicSplineCurve— natural cubic spline (C² continuous), Thomas algorithm, no linear-algebra dependencies.PchipCurve— Fritsch-Carlson monotone cubic Hermite (C¹). Use when cubic spline produces overshoots or when monotonicity must be preserved.NelsonSiegelCurve— Nelson-Siegel (1987) 4-parameter parametric fit.SvenssonCurve— Nelson-Siegel-Svensson (1994) 6-parameter parametric fit (BCB/ANBIMA/ECB standard for sovereign yield curves).
§Discount factors and forward rates
See the compounding module for free-standing helpers that turn
interpolated rates into discount factors and implied forward rates under
any of: continuous, periodic, or simple compounding.
§Bond pricing
See the bond module for price, Macaulay/modified duration, convexity
and par yield computed from a cash-flow schedule plus a YTM.
§Dates, day counts, calendars, and schedules
The date, daycount, calendar, and schedule modules form a
zero-dependency date toolkit for building a curve’s time axis: a proleptic
Gregorian Date, ISDA day-count conventions (DayCount), holiday
calendars (Calendar, Brazil, Target2) with business-day
adjustment and the BUS/252 year fraction, and coupon/pillar
Schedule generation.
§Conventions
The x-axis is time in years. Convert from calendar/business days at the call site with the appropriate day count convention:
- Brazil (business-day 252):
days / 252.0 - US Treasury (actual/365):
days / 365.0 - ISDA actual/365.25:
days / 365.25
Rates are in the same unit as the input (typically percent). The library performs no unit conversion.
§Extrapolation
All curves extrapolate flat outside the observed range — the rate of the nearest observed anchor is returned. Parametric methods (NS, Svensson) in particular diverge quickly outside the fitted range, so flat extrapolation is a sane default for financial use.
§Example
use yield_curves::{CubicSplineCurve, YieldCurveInterpolator};
// Brazilian nominal yield curve from LTNs/NTN-Fs (t in years, rate in %).
let points = [
(1.0, 13.98),
(2.5, 13.51),
(4.0, 13.45),
(7.0, 13.57),
(10.0, 13.80),
];
let curve = CubicSplineCurve::fit(&points).unwrap();
let rate_5y = curve.rate_at(5.0);
assert!((13.4..=13.6).contains(&rate_5y));Re-exports§
pub use calendar::easter;pub use calendar::Brazil;pub use calendar::BusinessDayConvention;pub use calendar::Calendar;pub use calendar::JoinCalendar;pub use calendar::JoinRule;pub use calendar::Target2;pub use calendar::WeekendsOnly;pub use compounding::discount_factor;pub use compounding::forward_rate;pub use compounding::Compounding;pub use date::Date;pub use date::DateError;pub use date::Period;pub use date::Unit;pub use date::Weekday;pub use daycount::DayCount;pub use linear::LinearCurve;pub use nelson_siegel::NelsonSiegelCurve;pub use pchip::PchipCurve;pub use schedule::third_wednesday;pub use schedule::DateGeneration;pub use schedule::Schedule;pub use schedule::ScheduleError;pub use schedule::StubConvention;pub use spline::CubicSplineCurve;pub use svensson::SvenssonCurve;
Modules§
- bond
- Bond pricing primitives — Tier 2 of the crate’s evolution (v0.3).
- calendar
- Holiday calendars, business-day adjustment, and BUS/252 — Phase 0.
- compounding
- Compounding conventions, discount factors, and forward rates.
- date
- Calendar dates, weekdays, and date periods — Phase 0 foundations.
- daycount
- Day-count conventions — year fractions between two
Dates. - linear
- Piecewise-linear interpolation with flat extrapolation.
- nelson_
siegel - Nelson-Siegel (1987) parametric yield curve.
- pchip
- Piecewise Cubic Hermite Interpolating Polynomial (PCHIP).
- schedule
- Schedule generation — coupon/pillar date sequences. Phase 0 finisher.
- spline
- Natural cubic spline interpolation.
- svensson
- Svensson (1994) parametric yield curve.
Enums§
- Yield
Curve Error - Errors returned by curve construction.
Traits§
- Yield
Curve Interpolator - Common interface for all yield curve methods.