Skip to main content

AnyCoupon

Enum AnyCoupon 

#[non_exhaustive]
pub enum AnyCoupon { Fixed(FixedRateCoupon), Ibor(IborCoupon), Overnight(OvernightCoupon), Redemption(Redemption), MultiReset(MultiResetCoupon), Cpi(CpiCoupon), RangeAccrual(RangeAccrualCoupon), CpiRedemption(CpiRedemption), Cms(CmsCoupon), YoyInflation(YoyInflationCoupon), }
Expand description

The closed coupon set.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

Implementations§

§

impl AnyCoupon

pub fn kind(&self) -> &'static str

The variant’s name — the word a cashflow table’s kind column carries.

Here rather than in the binding, which spelled the same four words out again. A word that names a variant is the core’s vocabulary, and a second copy of it is a second place to forget when a shape is added — which is exactly what #[non_exhaustive] stops the compiler from catching across the crate boundary.

§

impl AnyCoupon

pub fn payment_date(&self) -> NaiveDate

The date this coupon pays on.

pub fn payment_ordinal(&self) -> i32

The payment date as a proleptic-Gregorian day number, stored at build — what the leg walk hands a curve.

pub fn currency(&self) -> Currency

The currency this coupon pays in.

pub fn notional(&self) -> f64

The notional this coupon accrues on. A redemption accrues on nothing.

pub fn amount(&self) -> Option<f64>

The amount this flow pays, where the contract alone fixes it.

Some for a redemption — its stated amount — and for a fixed coupon, whose notional, rate and year fraction are all contract data. None for a coupon whose rate must be fixed or projected, because zero would be indistinguishable from a coupon that genuinely pays nothing; the reading that projects is cashflow_records, which takes a market for exactly that reason.

A redemption’s amount used to be unreachable: it is not a notional, so notional answers 0.0 for one — rightly — and no other reading existed. Callers were also writing this crate’s own formula out by hand to get a fixed coupon’s amount.

pub fn accrual_start(&self) -> Option<NaiveDate>

The date accrual begins. A redemption accrues over nothing and has none.

pub fn accrual_end(&self) -> Option<NaiveDate>

The date accrual ends. A redemption accrues over nothing and has none.

pub fn fixing_date(&self) -> Option<NaiveDate>

The date this coupon’s rate is fixed on, for a coupon whose rate is fixed on one date.

A fixed coupon’s rate was agreed on the term sheet, not observed; an overnight coupon observes a strip of dates rather than one, so it reports none here and its observations are the strip; a redemption has no rate at all.

pub fn contract_rate(&self) -> Option<f64>

The rate written on the contract, for a coupon that carries one.

Passive by construction — this is the term sheet’s number, not a projection. A floating coupon has none, because what it will pay is a market question; nor has a CPI coupon, whose written rate is paid on an indexed notional and so is not the rate it accrues.

pub fn index(&self) -> Option<&str>

The projection key this coupon resets against, or None for a coupon that carries its own rate.

The key a market is keyed by. It is the registry code the index wrote onto the coupon at build — the same string IborIndex::code documents as “the key a market stores the index’s projection curve and fixings under, and the one a coupon names”, and the same one AnyCoupon::rate already reads this coupon’s fixings under. So a walk holding several curves can ask each coupon which one it wants rather than being told once for a whole table — which is what lets a two-index product’s legs each project off their own curve.

A fixed coupon and a redemption name nothing: neither resets. A CPI coupon names a price index, which is no projection curve’s key: see price_index.

pub fn price_index(&self) -> Option<&str>

The price index a CPI coupon is scaled by — the inflation key a leg holding it declares — or None for any other coupon.

pub fn indices(&self) -> Vec<&str>

Every index the coupon reads a rate of: its own, and for a stub electing ISDA 2006 §8.3 Linear Interpolation — a term coupon’s, or a multi-reset coupon’s final reset — the two tenors it blends — what a leg holding it has to declare a curve for. Each index once, in the order read.

pub fn day_count(&self) -> Option<DayCountFraction>

The basis the coupon accrues on, or None for one that accrues over nothing.

A caller composing a leg out of an instrument’s own coupons needs this: without it the accrual can only be guessed, and a guess that is wrong prices a different trade.

pub fn year_fraction(&self) -> f64

The accrual year fraction, as stored at build. A redemption accrues over nothing.

pub fn rate<R: Scalar>( &self, fwd: Option<&dyn YieldCurve<R>>, fixings: &FixingsView<'_, R>, as_of: NaiveDate, ) -> Result<R, CashflowError>

The coupon rate in mode R, as of as_of.

A reset dated on or before as_of has already happened, so it is read from fixings and must be there: a historical reset that was never published is reported, not quietly projected, because projecting one prices a number the market never printed. A reset after as_of projects off fwd.

§Errors

CashflowError::MarketData for a missing historical fixing; CashflowError::Curve for a curve query, or where a coupon needs a projection and no forward curve was supplied.

pub fn rate_with<R: Scalar, C: CurveByIndex<R> + ?Sized>( &self, curves: &C, fixings: &FixingsView<'_, R>, as_of: NaiveDate, ) -> Result<R, CashflowError>

The coupon’s rate with each index it reads priced off its own curve.

The same as rate for every coupon but a stub electing ISDA 2006 §8.3 Linear Interpolation, which reads two Designated Maturities: each from the store where its print is published and otherwise projected over its own window off its own index’s curve, blended R_short + weight · (R_long − R_short). Gearing and spread apply to the blend.

§Errors

As rate, and CashflowError::NoCurveForIndex naming the tenor whose curve curves does not hold.

pub fn project_with<R: Scalar, C: CurveByIndex<R> + ?Sized>( &self, curves: &C, fixings: &FixingsView<'_, R>, as_of: NaiveDate, ) -> Result<Cashflow<R>, CashflowError>

project with each index priced off its own curve: see rate_with.

§Errors

As rate_with.

pub fn project<R: Scalar>( &self, fwd: Option<&dyn YieldCurve<R>>, fixings: &FixingsView<'_, R>, as_of: NaiveDate, ) -> Result<Cashflow<R>, CashflowError>

This coupon projected into mode R as a dated payment, as of as_of.

§Errors

As rate.

Trait Implementations§

§

impl Clone for AnyCoupon

§

fn clone(&self) -> AnyCoupon

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 AnyCoupon

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for AnyCoupon

§

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

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.