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
Fixed(FixedRateCoupon)
See FixedRateCoupon.
Ibor(IborCoupon)
See IborCoupon.
Overnight(OvernightCoupon)
See OvernightCoupon.
Redemption(Redemption)
See Redemption.
MultiReset(MultiResetCoupon)
See MultiResetCoupon.
Cpi(CpiCoupon)
See CpiCoupon.
RangeAccrual(RangeAccrualCoupon)
See RangeAccrualCoupon.
CpiRedemption(CpiRedemption)
See CpiRedemption.
Cms(CmsCoupon)
See CmsCoupon.
YoyInflation(YoyInflationCoupon)
See YoyInflationCoupon.
Implementations§
§impl AnyCoupon
impl AnyCoupon
pub fn kind(&self) -> &'static str
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
impl AnyCoupon
pub fn payment_date(&self) -> NaiveDate
pub fn payment_date(&self) -> NaiveDate
The date this coupon pays on.
pub fn payment_ordinal(&self) -> i32
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 amount(&self) -> Option<f64>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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.