pub struct YieldCurve { /* private fields */ }Expand description
A canonical discount curve anchored at reference_date.
State is the pillar (times, dfs) vectors only — dfs[0] = 1.0 at
times[0] = 0.0 always. compounding is the quoting convention used by
zero_rate / forward_rate;
changing it never changes discounting.
Implementations§
Source§impl YieldCurve
impl YieldCurve
Sourcepub fn flat(
rate: f64,
reference_date: NaiveDate,
day_count: DayCountConvention,
compounding: Compounding,
) -> Result<Self, CurveError>
pub fn flat( rate: f64, reference_date: NaiveDate, day_count: DayCountConvention, compounding: Compounding, ) -> Result<Self, CurveError>
Flat curve at a single rate quoted in compounding.
Sourcepub fn from_zero_rates(
tenors: &[Tenor],
rates: &[f64],
reference_date: NaiveDate,
day_count: DayCountConvention,
compounding: Compounding,
interpolation: InterpolationMethod,
) -> Result<Self, CurveError>
pub fn from_zero_rates( tenors: &[Tenor], rates: &[f64], reference_date: NaiveDate, day_count: DayCountConvention, compounding: Compounding, interpolation: InterpolationMethod, ) -> Result<Self, CurveError>
Curve from zero rates quoted in compounding.
Sourcepub fn from_discount_factors(
tenors: &[Tenor],
dfs: &[f64],
reference_date: NaiveDate,
day_count: DayCountConvention,
compounding: Compounding,
interpolation: InterpolationMethod,
) -> Result<Self, CurveError>
pub fn from_discount_factors( tenors: &[Tenor], dfs: &[f64], reference_date: NaiveDate, day_count: DayCountConvention, compounding: Compounding, interpolation: InterpolationMethod, ) -> Result<Self, CurveError>
Curve directly from discount factors.
Sourcepub fn from_forward_rates(
tenors: &[Tenor],
forwards: &[f64],
reference_date: NaiveDate,
day_count: DayCountConvention,
compounding: Compounding,
interpolation: InterpolationMethod,
) -> Result<Self, CurveError>
pub fn from_forward_rates( tenors: &[Tenor], forwards: &[f64], reference_date: NaiveDate, day_count: DayCountConvention, compounding: Compounding, interpolation: InterpolationMethod, ) -> Result<Self, CurveError>
Curve from forward rates: forwards[i] applies between tenor i-1
(or the reference date for i = 0) and tenor i, quoted in
compounding.
Sourcepub fn from_input(
input: &CurveInput,
reference_date: NaiveDate,
) -> Result<Self, CurveError>
pub fn from_input( input: &CurveInput, reference_date: NaiveDate, ) -> Result<Self, CurveError>
Build from a deserialized CurveInput, anchored at reference_date.
Sourcepub fn bumped(&self, shift: &RateShift) -> Result<YieldCurve, CurveError>
pub fn bumped(&self, shift: &RateShift) -> Result<YieldCurve, CurveError>
This curve with shift applied to its continuous zero rates.
The discount factors are re-derived exactly at the affected pillars:
z -> z + d gives df -> df * exp(-d*t), z -> z*(1+r) gives
df -> df^(1+r). Day count, quoting convention and interpolation
are unchanged; df(0) = 1 is preserved. A key-rate shift may add
pillars (see RateShift::KeyRateAbsolute); parallel shifts never
do. Errors only on a malformed key-rate shift.
Sourcepub fn min_forward(&self) -> ForwardSegment
pub fn min_forward(&self) -> ForwardSegment
The inter-pillar segment with the smallest discrete continuous
forward ln(df(t1)/df(t2)) / (t2 - t1) — the no-arbitrage
diagnostic: a value below zero means the discount factors increase
somewhere. Checking consecutive pillars suffices: under
InterpolationMethod::LogLinearDf this is the instantaneous
forward on the segment; under LinearZero it is the segment
average. The first segment starts at the t = 0 anchor.
Sourcepub fn df(&self, t: f64) -> f64
pub fn df(&self, t: f64) -> f64
Discount factor at year fraction t from the reference date.
t <= 0 returns 1.0; beyond the last pillar the last continuously
compounded zero rate is extrapolated flat.
Sourcepub fn df_date(&self, date: NaiveDate) -> f64
pub fn df_date(&self, date: NaiveDate) -> f64
Discount factor at an absolute date (via the curve’s day count).
Sourcepub fn zero_rate_with(&self, t: f64, compounding: Compounding) -> f64
pub fn zero_rate_with(&self, t: f64, compounding: Compounding) -> f64
Zero rate at t in an explicit convention.
Sourcepub fn forward_rate(&self, t1: f64, t2: f64) -> Result<f64, CurveError>
pub fn forward_rate(&self, t1: f64, t2: f64) -> Result<f64, CurveError>
Forward rate between t1 and t2 in the curve’s quoting convention.
Sourcepub fn forward_rate_with(
&self,
t1: f64,
t2: f64,
compounding: Compounding,
) -> Result<f64, CurveError>
pub fn forward_rate_with( &self, t1: f64, t2: f64, compounding: Compounding, ) -> Result<f64, CurveError>
Forward rate between t1 and t2 in an explicit convention
(Simple gives the FRA-style forward).
pub fn reference_date(&self) -> NaiveDate
pub fn day_count(&self) -> DayCountConvention
pub fn compounding(&self) -> Compounding
Sourcepub fn pillars(&self) -> Vec<CurvePillar>
pub fn pillars(&self) -> Vec<CurvePillar>
The curve’s pillars (excluding the synthetic t=0 node) with derived
continuously compounded zero rates — for inspection and display;
always computed fresh from the stored dfs so it cannot disagree with
what df(t) returns.
Trait Implementations§
Source§impl Clone for YieldCurve
impl Clone for YieldCurve
Source§fn clone(&self) -> YieldCurve
fn clone(&self) -> YieldCurve
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more