Skip to main content

Projections

Struct Projections 

pub struct Projections<'a, R: Scalar> {
    entries: Vec<(&'a str, &'a dyn YieldCurve<R>)>,
}
Expand description

The projection curves a table may read, each under the key the market resolved it from.

A coupon is projected off the curve it names. A table over several legs cannot take one forward curve: a tenor basis swap’s two legs reset against two different indices, and handing both the first leg’s curve reports the second leg off a curve it does not use. Every coupon already carries its index’s registry code, and that code is what the market keys its projection curves by, so the walk asks the coupon rather than the caller.

This is one CurveByIndex source among several: a pricing view answers the same question from the declaration it carries, so an instrument’s table is produced straight off its view, and this pairing serves a caller holding loose curves — a bare leg priced outside any instrument.

Bounded and searched linearly because it holds at most a handful of entries; a map would cost more to build than the scan it saves.

Fields§

§entries: Vec<(&'a str, &'a dyn YieldCurve<R>)>

Implementations§

§

impl<'a, R: Scalar> Projections<'a, R>

pub fn none() -> Self

No projection curve at all — a table over fixed coupons only.

pub fn of(key: &'a str, curve: &'a dyn YieldCurve<R>) -> Self

The curve resolved under key.

pub fn and(self, key: &'a str, curve: &'a dyn YieldCurve<R>) -> Self

This pairing with one more key.

pub fn get(&self, key: Option<&str>) -> Option<&'a dyn YieldCurve<R>>

The curve a coupon naming key projects off, or None where the pairing holds no such key and where the coupon names none.

A missing key yields no curve rather than a substitute. Handing back some other curve is how a leg comes to be reported off a curve it never reads. A coupon whose reset has already fixed needs no curve at all and is unaffected; one that must project and has none raises its own refusal, which already exists and names the problem.

Trait Implementations§

§

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

§

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. Read more
§

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. Read more
§

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

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, R> !RefUnwindSafe for Projections<'a, R>

§

impl<'a, R> !Send for Projections<'a, R>

§

impl<'a, R> !Sync for Projections<'a, R>

§

impl<'a, R> !UnwindSafe for Projections<'a, R>

§

impl<'a, R> Freeze for Projections<'a, R>

§

impl<'a, R> Unpin for Projections<'a, R>

§

impl<'a, R> UnsafeUnpin for Projections<'a, R>

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> 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, 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.