Skip to main content

CurveByIndex

Trait CurveByIndex 

pub trait CurveByIndex<R: Scalar> {
    // Required method
    fn curve(&self, index: &str) -> Option<&dyn YieldCurve<R>>;

    // Provided methods
    fn curve_of(&self, index: Option<&str>) -> Option<&dyn YieldCurve<R>> { ... }
    fn distinguishes_indices(&self) -> bool { ... }
    fn cms_rate(
        &self,
        _coupon: &CmsCoupon,
        _as_of: NaiveDate,
    ) -> Option<Result<R, CashflowError>> { ... }
    fn cap_vol(&self, _currency: Currency) -> Option<&RateSmileView<'_, R>> { ... }
    fn yoy_vol(&self, _index: &str) -> Option<&InflationVolView<'_, R>> { ... }
    fn cpi_vol(&self, _index: &str) -> Option<&InflationVolView<'_, R>> { ... }
    fn index_level(
        &self,
        _index: &str,
        _lag_months: u32,
        _date: NaiveDate,
    ) -> Result<Option<R>, CashflowError> { ... }
}
Expand description

Projection curves, by the index that names them.

A coupon is projected off the curve its index names. Every floating coupon carries its index’s registry code, and that code is what a market keys its projection curves by, so a leg asks this for each coupon rather than taking one curve for all of them. That is what lets one leg carry coupons on two indices — a stub read off two tenors’ curves, a basis leg beside its base — without the caller routing curves by position.

Three sources implement it: a pricing view (from the declaration it was resolved for, so an index the product did not declare gets no curve), the record walk’s key-to-curve pairing, and OneCurve, which answers every index with one curve and is how a caller holding a single curve prices a single-index leg exactly as before.

A leg takes the source as a type parameter rather than a &dyn, so the single-curve adapter’s answer inlines to the curve it holds and a single-index leg pays nothing per coupon for the lookup; a &dyn source still fits, being ?Sized.

Required Methods§

fn curve(&self, index: &str) -> Option<&dyn YieldCurve<R>>

The curve a coupon naming index projects off, or None where this source holds no curve for it.

A missing index yields no curve rather than a substitute. Handing back some other curve is how a leg comes to be valued off a curve it never reads. A coupon whose reset has already fixed needs no curve and is unaffected; one that must project and has none raises a refusal naming the index.

Provided Methods§

fn curve_of(&self, index: Option<&str>) -> Option<&dyn YieldCurve<R>>

curve for a coupon’s own index, which a fixed coupon does not have.

fn distinguishes_indices(&self) -> bool

Whether two different indices can be answered with two different curves. A source holding one curve for every index cannot, and a stub that interpolates between two tenors must not be valued through it: it would blend one curve with itself.

fn cms_rate( &self, _coupon: &CmsCoupon, _as_of: NaiveDate, ) -> Option<Result<R, CashflowError>>

What a CMS coupon still to fix pays as a rate — the CMS rate its swap index fixes, convexity-adjusted off the swaption smile, geared, spread and with its payoff — or None where this source cannot replicate it: a curve source holds no discount curve and no swaption vols, and the coupon is then refused by name.

fn cap_vol(&self, _currency: Currency) -> Option<&RateSmileView<'_, R>>

The cap vol surface a capped or floored coupon in currency values its options off, or None where this source holds none — a curve source is not a vol source, and a coupon’s option still to fix is then refused by name rather than valued at its forward.

fn yoy_vol(&self, _index: &str) -> Option<&InflationVolView<'_, R>>

The year-on-year optionlet vol surface a capped, floored or digital YoY inflation coupon on index values its options off, or None where this source holds none — and the option still to fix is then refused by name.

fn cpi_vol(&self, _index: &str) -> Option<&InflationVolView<'_, R>>

The zero-coupon CPI option vol surface a collared CPI notional on index values its options off, or None where this source holds none — and the option still to fix is then refused by name.

fn index_level( &self, _index: &str, _lag_months: u32, _date: NaiveDate, ) -> Result<Option<R>, CashflowError>

The level of price index index a flow on date is scaled by, under the index’s lag and interpolation, or None where this source holds no inflation for it — a curve source is not an index source, and a CPI coupon is then refused by name.

§Errors

Whatever the inflation curve reports.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl<R: Scalar> CurveByIndex<R> for NoCurve

§

impl<R: Scalar> CurveByIndex<R> for OneCurve<'_, R>

§

impl<R: Scalar> CurveByIndex<R> for PricingView<'_, R>

§

impl<R: Scalar> CurveByIndex<R> for Projections<'_, R>