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: DayCountFractionImplementations§
§impl PiecewiseInflation
impl PiecewiseInflation
pub fn new(
reference_date: NaiveDate,
nodes: &[(NaiveDate, f64)],
interp: LevelInterpolation,
day_count: DayCountFraction,
) -> Result<Self, CurveError>
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
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
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]
pub fn node_dates(&self) -> &[NaiveDate]
The node dates, in order.
pub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
The free parameters — the level at each node.
pub fn interpolation(&self) -> LevelInterpolation
pub fn interpolation(&self) -> LevelInterpolation
The level space nodes are interpolated in.
pub fn day_count(&self) -> DayCountFraction
pub fn day_count(&self) -> DayCountFraction
The day count the curve measures time under.
pub fn view<R: Scalar>(&self) -> PiecewiseInflationView<'_, R>
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>
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>
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
impl Clone for PiecewiseInflation
§fn clone(&self) -> PiecewiseInflation
fn clone(&self) -> PiecewiseInflation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for PiecewiseInflation
impl Debug for PiecewiseInflation
§impl PartialEq for PiecewiseInflation
impl PartialEq for PiecewiseInflation
§fn eq(&self, other: &PiecewiseInflation) -> bool
fn eq(&self, other: &PiecewiseInflation) -> bool
self and other values to be equal, and is used by ==.