Trait Product
pub trait Product {
// Required methods
fn currency(&self) -> Currency;
fn legs(&self) -> Option<Vec<&Leg>>;
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>;
// Provided methods
fn final_payment_date(&self) -> Option<NaiveDate> { ... }
fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument> { ... }
fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument> { ... }
}Expand description
What every built-in product states about itself, beside how it is priced.
Each product answers in its own module, next to its struct, so a new
product states these where it is defined rather than as a new arm in a match
here. AnyInstrument forwards through dispatch!.
Required Methods§
fn currency(&self) -> Currency
fn currency(&self) -> Currency
The currency the product pays in. An FX product values in its quote currency; a book converts.
fn legs(&self) -> Option<Vec<&Leg>>
fn legs(&self) -> Option<Vec<&Leg>>
The legs the product itself holds, in a declared order, or None
for a product that holds none — see AnyInstrument::legs. No
default: every product states which it is.
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
The contract dates the product resolved to, as (name, date) pairs —
exactly the dates its stated constructor takes, so a product built
through a derived form can be read back and rebuilt through the stated
one. Empty for a product with no stated form. No default: every
product states which it is — see AnyInstrument::contract_dates.
Provided Methods§
fn final_payment_date(&self) -> Option<NaiveDate>
fn final_payment_date(&self) -> Option<NaiveDate>
The date of the product’s final payment, where a calibration rung can
be built on it; None for a product no ladder is built from.
fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
This product re-struck at the par rate rate — the scalar a par
calibration rung on it is quoted in — or None for a product that
carries no such scalar. What a quote scenario moves a rung to.
fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>
fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>
This product re-struck at the basis spread spread on its spread
leg, or None for a product that quotes none.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
§impl<T: Product + ?Sized> Product for Box<T>
A boxed product states what the product inside it states, so the boxed
variants forward like the rest.
impl<T: Product + ?Sized> Product for Box<T>
A boxed product states what the product inside it states, so the boxed variants forward like the rest.