Skip to main content

ExponentialSplines

Struct ExponentialSplines 

pub struct ExponentialSplines {
    reference_date: NaiveDate,
    params: Vec<f64>,
}
Expand description

An exponential-splines discount curve (the Vasicek-Fong family).

DF(τ) = Σₖ βₖ·e^{−k·α·τ} / Σₖ βₖ,   k = 1 … N

A basis of decaying exponentials at multiples of one decay rate. N + 1 parameters, stored [β₁ … β_N, ln α].

DF(0) = 1 by construction, and by normalisation rather than by constraint: every basis function is one at the origin, so dividing by the coefficient sum makes the value there exactly one whatever the coefficients are. No parameter is privileged and the solver steps all of them freely.

Unlike the two shapes above, this one does not guarantee positive, decreasing discount factors — so a fit of it is checked afterwards. See validity.

Fields§

§reference_date: NaiveDate§params: Vec<f64>

[β₁ … β_N, ln α].

Implementations§

§

impl ExponentialSplines

pub fn new( reference_date: NaiveDate, betas: &[f64], alpha: f64, ) -> Result<Self, CurveError>

An exponential-splines curve from coefficients and a decay.

§Errors

CurveError::NonFinite for a non-finite parameter, a decay that is not strictly positive, an empty basis, or coefficients summing to zero — which the normalisation would divide by.

pub fn reference_date(&self) -> NaiveDate

The curve’s reference date.

pub fn basis(&self) -> usize

How many basis functions the curve carries.

pub fn alpha(&self) -> f64

The decay, exponentiated back out of its stored logarithm.

pub fn parameters(&self) -> &[f64]

The free parameters, [β₁ … β_N, ln α].

pub fn validity(&self, horizon: NaiveDate) -> Result<(), NaiveDate>

Whether the curve’s discount factors are positive and decreasing across horizon, sampled monthly.

The form gives no such guarantee, so a fit of it is checked here rather than trusted. Sampling the horizon and not the fitted points is the point: a curve invalid only between its inputs prices most of them acceptably, which is exactly how the failure hides.

§Errors

The first date at which the curve is not a discount curve — where a factor is non-positive, non-finite, or larger than the one before it.

pub fn view<R: Scalar>(&self) -> ExponentialSplinesView<'_, R>

This curve lifted into mode R.

pub(crate) fn view_with_slice<'a, R: Scalar>( &'a self, rest: &mut &'a [R], ) -> ExponentialSplinesView<'a, R>

One step of a substituted walk.

pub(crate) fn view_seeding<R: Scalar + Seedable>( &self, seed: &mut Option<usize>, ) -> ExponentialSplinesView<'_, R>

One step of a seeded walk.

Trait Implementations§

§

impl Clone for ExponentialSplines

§

fn clone(&self) -> ExponentialSplines

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
§

impl Debug for ExponentialSplines

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for ExponentialSplines

§

fn eq(&self, other: &ExponentialSplines) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for ExponentialSplines

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