Skip to main content

PiecewiseInflation

Struct PiecewiseInflation 

pub struct PiecewiseInflation {
    reference_date: NaiveDate,
    dates: Vec<NaiveDate>,
    taus: Vec<f64>,
    levels: Vec<f64>,
    interp: LevelInterpolation,
    seasonality: Option<[f64; 12]>,
    day_count: DayCountFraction,
}
Expand description

A piecewise inflation curve over (date, level) nodes, with optional twelve-month seasonality.

Unlike a discount or survival curve there is no unit anchor: an index level at the reference date is a quoted number like any other, so every node is a free parameter and none of them is implicit.

Seasonality is a property of the curve, not of a coupon: it reshapes the interpolated level by the query month’s factor, so a coupon stays seasonality-agnostic and two curves differing only in seasonality are two curves rather than one curve read two ways.

It reshapes within a year and does not move the curve: the factors are normalised by the one belonging to the first node’s month, so that node — the level the curve is anchored to, usually the last published print — reads back unchanged. Applying the raw factors instead would scale the anchor by its own factor, and a curve built from a print would stop reproducing it.

Fields§

§reference_date: NaiveDate§dates: Vec<NaiveDate>§taus: Vec<f64>§levels: Vec<f64>

The free parameters: the index level at each node.

§interp: LevelInterpolation§seasonality: Option<[f64; 12]>

Twelve monthly factors, index 0 = January.

§day_count: DayCountFraction

Implementations§

§

impl PiecewiseInflation

pub fn new( reference_date: NaiveDate, nodes: &[(NaiveDate, f64)], interp: LevelInterpolation, day_count: DayCountFraction, ) -> Result<Self, CurveError>

A curve from (date, index level) nodes.

§Errors

CurveError::Malformed if there are no nodes, if the dates are not strictly ascending, or if a level is not strictly positive — a non-positive level makes the index ratios a coupon needs undefined.

pub fn with_seasonality(self, factors: [f64; 12]) -> Self

This curve with twelve monthly seasonality factors attached, index 0 = January.

The factors are read as a ratio against the first node’s month, so only their relative shape matters: multiplying all twelve by a constant changes nothing, and the curve’s anchor reads back unchanged whatever they are. A caller whose factors are published against a different starting month rotates the array; there is no base-month argument because a rotation is the whole of what one would do.

fn anchor_month0(&self) -> usize

The month whose factor every other is read against: the first node’s, which is the level this curve is anchored to.

pub fn node_dates(&self) -> &[NaiveDate]

The node dates, in order.

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

The free parameters — the level at each node.

pub fn interpolation(&self) -> LevelInterpolation

The level space nodes are interpolated in.

pub fn day_count(&self) -> DayCountFraction

The day count the curve measures time under.

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

This curve lifted into mode R.

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

One step of a substituted walk. See take_params.

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

One step of the seeded walk. See take_seed.

Trait Implementations§

§

impl Clone for PiecewiseInflation

§

fn clone(&self) -> PiecewiseInflation

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 PiecewiseInflation

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for PiecewiseInflation

§

fn eq(&self, other: &PiecewiseInflation) -> 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 PiecewiseInflation

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.