Struct TenorBasisSwap
pub struct TenorBasisSwap {
pub currency: Currency,
pub collateral: CollateralSpec,
pub spread_index: String,
pub base_index: String,
pub spread_leg: Leg,
pub base_leg: Leg,
pub spread: f64,
}Expand description
A single-currency tenor basis swap: a spread leg on one index, carrying the basis spread, received against a base leg on another index, paid. Each leg has its own schedule, day count and index window.
Fields§
§currency: CurrencyThe swap’s currency.
collateral: CollateralSpecWhat both legs are discounted against.
spread_index: StringThe spread leg’s index, by registry code.
base_index: StringThe base leg’s index, by registry code.
spread_leg: LegThe spread leg, received, its coupons carrying spread.
base_leg: LegThe base leg, paid.
spread: f64The basis spread on the spread leg, as a decimal.
Implementations§
§impl TenorBasisSwap
impl TenorBasisSwap
pub fn from_template(
template: &TenorBasisTemplate,
effective: NaiveDate,
termination: NaiveDate,
notional: f64,
spread: f64,
) -> Result<Self, CurveError>
pub fn from_template( template: &TenorBasisTemplate, effective: NaiveDate, termination: NaiveDate, notional: f64, spread: f64, ) -> Result<Self, CurveError>
A swap from its template between two dates, at spread on the
template’s spread leg.
§Errors
CurveError::UnknownIndex if a template’s index code is not a
registered term or overnight index, and
CurveError::InvertedDates if termination is not after
effective.
pub fn from_legs(
spread_leg: &TenorBasisLeg,
base_leg: &TenorBasisLeg,
effective: NaiveDate,
termination: NaiveDate,
notional: f64,
spread: f64,
) -> Result<Self, CurveError>
pub fn from_legs( spread_leg: &TenorBasisLeg, base_leg: &TenorBasisLeg, effective: NaiveDate, termination: NaiveDate, notional: f64, spread: f64, ) -> Result<Self, CurveError>
A swap from two leg conventions between two dates, at spread on
spread_leg (received) against base_leg (paid). Both legs generate
forward from effective on their own conventions and project over
their index’s window. The legs may be a template’s in either order:
which index carries the basis is the trade’s, not the template’s.
§Errors
CurveError::UnknownIndex if a leg’s index code is not a registered
term or overnight index — a template is plain data a user edits, so a
mistyped code is reported, not a reason to abort the pricing thread —
and CurveError::InvertedDates if termination is not after
effective.
Trait Implementations§
§impl Clone for TenorBasisSwap
impl Clone for TenorBasisSwap
§fn clone(&self) -> TenorBasisSwap
fn clone(&self) -> TenorBasisSwap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for TenorBasisSwap
impl Debug for TenorBasisSwap
§impl PartialEq for TenorBasisSwap
impl PartialEq for TenorBasisSwap
§impl<R: Scalar> Priceable<R> for TenorBasisSwap
impl<R: Scalar> Priceable<R> for TenorBasisSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
The spread leg received on its index’s curve, the base leg paid on its own, both discounted on the collateral curve.
§fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
The fair basis: the spread on the spread leg that zeroes the swap,
s − npv(s) / annuity, off the spread leg’s own annuity — the value
is exactly affine in the spread, so this is a division.
§fn par_rate(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>
fn par_rate(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>
§impl PricingRiskFactors for TenorBasisSwap
impl PricingRiskFactors for TenorBasisSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
§impl Product for TenorBasisSwap
impl Product for TenorBasisSwap
§fn restruck_at_spread(&self, spread: f64) -> Option<AnyInstrument>
fn restruck_at_spread(&self, spread: f64) -> Option<AnyInstrument>
spread on its spread
leg, or None for a product that quotes none.§fn currency(&self) -> Currency
fn currency(&self) -> Currency
§fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
(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.§fn legs(&self) -> Option<Vec<&Leg>>
fn legs(&self) -> Option<Vec<&Leg>>
None
for a product that holds none — see AnyInstrument::legs. No
default: every product states which it is.§fn final_payment_date(&self) -> Option<NaiveDate>
fn final_payment_date(&self) -> Option<NaiveDate>
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>
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.