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: CurrencyThe swap’s currency.
index: StringThe price index, by registry code.
collateral: CollateralSpecWhat 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: f64The notional.
fixed_rate: f64The fixed rate, as a decimal.
day_count: DayCountFractionThe accrual day count each period’s year fraction is taken on.
lag_months: u32The indexation lag, in whole months.
side: f64+1 pays the fixed rate and receives inflation; −1 the reverse.
Implementations§
§impl YoyInflationSwap
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
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
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
pub fn receiver(self) -> Self
The side receiving the fixed rate and paying inflation.
pub fn with_fixed_rate(self, fixed_rate: f64) -> Self
pub fn with_fixed_rate(self, fixed_rate: f64) -> Self
Sets the fixed rate.
pub fn accruing(self, day_count: DayCountFraction) -> Self
pub fn accruing(self, day_count: DayCountFraction) -> Self
Sets the accrual day count.
§impl YoyInflationSwap
impl YoyInflationSwap
fn walk<R: Scalar>(
&self,
view: &PricingView<'_, R>,
) -> Result<Vec<(R, f64, R)>, PricingError>
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
Trait Implementations§
§impl Clone for YoyInflationSwap
impl Clone for YoyInflationSwap
§fn clone(&self) -> YoyInflationSwap
fn clone(&self) -> YoyInflationSwap
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 YoyInflationSwap
impl Debug for YoyInflationSwap
§impl PartialEq for YoyInflationSwap
impl PartialEq for YoyInflationSwap
§fn eq(&self, other: &YoyInflationSwap) -> bool
fn eq(&self, other: &YoyInflationSwap) -> bool
self and other values to be equal, and is used by ==.§impl<R: Scalar> Priceable<R> for YoyInflationSwap
impl<R: Scalar> Priceable<R> for YoyInflationSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
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>
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>
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
impl PricingRiskFactors for YoyInflationSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
§impl Product for YoyInflationSwap
impl Product for YoyInflationSwap
§fn currency(&self) -> Currency
fn currency(&self) -> Currency
§fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
(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>>
fn legs(&self) -> Option<Vec<&Leg>>
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>
fn final_payment_date(&self) -> Option<NaiveDate>
None for a product no ladder is built from.§fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
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>
fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>
spread on its spread
leg, or None for a product that quotes none.