Skip to main content

YieldCurve

Struct YieldCurve 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn from_input( input: &CurveInput, reference_date: NaiveDate, ) -> Result<Self, CurveError>

Build from a deserialized CurveInput, anchored at reference_date.

Source

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.

Source

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.

Source

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.

Source

pub fn df_date(&self, date: NaiveDate) -> f64

Discount factor at an absolute date (via the curve’s day count).

Source

pub fn zero_rate(&self, t: f64) -> f64

Zero rate at t in the curve’s quoting convention.

Source

pub fn zero_rate_with(&self, t: f64, compounding: Compounding) -> f64

Zero rate at t in an explicit convention.

Source

pub fn forward_rate(&self, t1: f64, t2: f64) -> Result<f64, CurveError>

Forward rate between t1 and t2 in the curve’s quoting convention.

Source

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).

Source

pub fn reference_date(&self) -> NaiveDate

Source

pub fn day_count(&self) -> DayCountConvention

Source

pub fn compounding(&self) -> Compounding

Source

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

Source§

fn clone(&self) -> YieldCurve

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for YieldCurve

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for YieldCurve

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for YieldCurve

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V