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>
impl<'a, R: Scalar> Projections<'a, R>
pub fn none() -> Self
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
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
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>>
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>
impl<R: Scalar> CurveByIndex<R> for Projections<'_, R>
§fn curve(&self, index: &str) -> Option<&dyn YieldCurve<R>>
fn curve(&self, index: &str) -> Option<&dyn YieldCurve<R>>
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>>
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
fn distinguishes_indices(&self) -> bool
§fn cms_rate(
&self,
_coupon: &CmsCoupon,
_as_of: NaiveDate,
) -> Option<Result<R, CashflowError>>
fn cms_rate( &self, _coupon: &CmsCoupon, _as_of: NaiveDate, ) -> Option<Result<R, CashflowError>>
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>>
fn cap_vol(&self, _currency: Currency) -> Option<&RateSmileView<'_, R>>
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>>
fn yoy_vol(&self, _index: &str) -> Option<&InflationVolView<'_, R>>
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>>
fn cpi_vol(&self, _index: &str) -> Option<&InflationVolView<'_, R>>
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>
fn index_level( &self, _index: &str, _lag_months: u32, _date: NaiveDate, ) -> Result<Option<R>, CashflowError>
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