Skip to main content

YoyInflationSwap

Struct YoyInflationSwap 

pub struct YoyInflationSwap {
    pub currency: Currency,
    pub index: String,
    pub collateral: CollateralSpec,
    pub dates: Vec<NaiveDate>,
    pub notional: f64,
    pub fixed_rate: f64,
    pub day_count: DayCountFraction,
    pub lag_months: u32,
    pub side: f64,
}
Expand description

A year-on-year inflation swap: a strip of annual index ratios against a strip of fixed coupons, each period settling on its own end date.

The same observation rule as the zero-coupon swap, applied once per period rather than once over the life — which is the only difference between them.

Fields§

§currency: Currency

The swap’s currency.

§index: String

The price index, by registry code.

§collateral: CollateralSpec

What the swap is collateralised against.

§dates: Vec<NaiveDate>

The period boundaries: n + 1 dates delimiting n annual periods. The first is the base observation and pays nothing; each of the rest is both its period’s observation and its payment date.

§notional: f64

The notional.

§fixed_rate: f64

The fixed rate, as a decimal.

§day_count: DayCountFraction

The accrual day count each period’s year fraction is taken on.

§lag_months: u32

The indexation lag, in whole months.

§side: f64

+1 pays the fixed rate and receives inflation; −1 the reverse.

Implementations§

§

impl YoyInflationSwap

pub fn new( currency: Currency, index: impl Into<String>, base_date: NaiveDate, maturity: NaiveDate, notional: f64, fixed_rate: f64, lag_months: u32, ) -> Self

A payer of the fixed rate, over annual periods from base_date up to and including maturity.

The boundaries are generated by the crate’s own calendar-blind period arithmetic and are unadjusted: an inflation observation is a month’s published number, so rolling its date to a business day changes nothing it reads. A caller wanting adjusted payment dates supplies the dates directly through from_dates.

A maturity on or before base_date yields a swap with no periods, which values at zero.

pub fn from_dates( currency: Currency, index: impl Into<String>, dates: Vec<NaiveDate>, notional: f64, fixed_rate: f64, lag_months: u32, ) -> Self

A swap over caller-supplied boundaries: n + 1 dates for n periods.

pub fn receiver(self) -> Self

The side receiving the fixed rate and paying inflation.

pub fn with_fixed_rate(self, fixed_rate: f64) -> Self

Sets the fixed rate.

pub fn accruing(self, day_count: DayCountFraction) -> Self

Sets the accrual day count.

pub fn periods(&self) -> Vec<(NaiveDate, NaiveDate, f64)>

The periods, as (observation start, observation end, year fraction).

One walk, so the valuation and the par rate cannot disagree about how many periods there are or what each accrues.

§

impl YoyInflationSwap

fn walk<R: Scalar>( &self, view: &PricingView<'_, R>, ) -> Result<Vec<(R, f64, R)>, PricingError>

One walk over the periods still to pay: each one’s annual index ratio, its year fraction and its pay-date discount factor.

The valuation and the par rate both read this, so they cannot disagree about which periods are live or what each observes.

§Errors

As ZeroCouponInflationSwap::index_ratio.

Trait Implementations§

§

impl Clone for YoyInflationSwap

§

fn clone(&self) -> YoyInflationSwap

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 YoyInflationSwap

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for YoyInflationSwap

§

fn eq(&self, other: &YoyInflationSwap) -> 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<R: Scalar> Priceable<R> for YoyInflationSwap

§

fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

side · Σ N·τ_i·((ratio_i − 1) − K) · DF(end_i) over the periods still to pay.

§

fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The fixed rate that values the swap at zero: the annuity-weighted average of the periods’ index growth.

§

fn par_spread(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>

Unsupported: the swap is quoted as a rate, and its floating side carries no margin a breakeven would be taken over.

§

impl PricingRiskFactors for YoyInflationSwap

§

fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>

The market data this product is priced against. Read more
§

impl Product for YoyInflationSwap

§

fn currency(&self) -> Currency

The currency the product pays in. An FX product values in its quote currency; a book converts.
§

fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>

The contract dates the product resolved to, as (name, date) pairs — exactly the dates its stated constructor takes, so a product built through a derived form can be read back and rebuilt through the stated one. Empty for a product with no stated form. No default: every product states which it is — see AnyInstrument::contract_dates.
§

fn legs(&self) -> Option<Vec<&Leg>>

The legs the product itself holds, in a declared order, or None for a product that holds none — see AnyInstrument::legs. No default: every product states which it is.
§

fn final_payment_date(&self) -> Option<NaiveDate>

The date of the product’s final payment, where a calibration rung can be built on it; None for a product no ladder is built from.
§

fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>

This product re-struck at the par rate rate — the scalar a par calibration rung on it is quoted in — or None for a product that carries no such scalar. What a quote scenario moves a rung to.
§

fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>

This product re-struck at the basis spread spread on its spread leg, or None for a product that quotes none.
§

impl StructuralPartialEq for YoyInflationSwap

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.