Skip to main content

VanillaSwap

Struct VanillaSwap 

pub struct VanillaSwap {
    pub fixed: Leg,
    pub floating: Leg,
    pub currency: Currency,
    pub index: String,
    pub collateral: CollateralSpec,
    pub stated_dates: Option<StatedDates>,
    pub foreign_collateral: Option<CollateralSpec>,
    others: Vec<String>,
}
Expand description

A fixed-versus-IBOR swap.

Two compiled legs and the identifiers naming what they are priced against. The fixed rate is not stored here separately: it is already on every coupon of the fixed leg, and holding it twice invites the two to disagree.

Fields§

§fixed: Leg

The fixed leg.

§floating: Leg

The floating leg.

§currency: Currency

The swap’s currency.

§index: String

The projection index the floating leg resets against.

§collateral: CollateralSpec

What the swap is collateralised against.

§stated_dates: Option<StatedDates>

The unadjusted dates the swap’s schedule was generated from, where it was built from dates rather than assembled from legs. A swap rebuilt from them generates the same schedule, which its adjusted accrual dates would not promise: a rolled termination can generate a stub.

§foreign_collateral: Option<CollateralSpec>

For a non-deliverable swap, the key of its own currency’s discount curve under the settlement currency’s collateral — the curve its payments convert at the parity forward on; None for a swap paid in its own currency.

§others: Vec<String>

Every index the floating leg reads besides index, each once in the order read — the tenors an ISDA 2006 §8.3 interpolated stub blends. Derived from the leg in new and owned here, so the swap’s declaration can borrow them: the first as its second projection, the rest as its projection basket.

Implementations§

§

impl VanillaSwap

pub fn new( fixed: Leg, floating: Leg, currency: Currency, index: impl Into<String>, collateral: CollateralSpec, ) -> Self

A swap from two compiled legs.

The swap takes from the floating leg every index it reads besides index — both tenors of a stub interpolating two tenors unlike the leg’s own — and declares each: the first as its second projection, the rest in its projection basket.

pub(crate) fn other_indices(&self) -> &[String]

Every index the floating leg reads besides index, each once in the order read: the first is declared as the second projection, the rest in the projection basket.

pub fn settled_in( self, settlement: Currency, fx_index: impl Into<FixingSource>, fixed_fixings: Vec<Conversion>, floating_fixings: Vec<Conversion>, ) -> Result<Self, NonDeliverableError>

This swap settling non-deliverably in settlement: each leg’s payments converted at the fx_index fixing on the matching date — one per payment, fixed leg then floating — discounted on settlement’s curve, the conversion’s forward read off this currency’s curve under settlement collateral.

§Errors

NonDeliverableError as Leg::with_non_deliverable refuses either leg.

pub fn with_stated_dates( self, effective: NaiveDate, termination: NaiveDate, ) -> Self

This swap stating the unadjusted dates its schedule was generated from.

§

impl VanillaSwap

fn floating_curves<'v, R: Scalar>( &self, view: &'v PricingView<'_, R>, fwd: &'v OneCurve<'v, R>, ) -> &'v dyn CurveByIndex<R>

The source the floating leg reads its curves from. A leg with an interpolated stub reads its tenors, each off its declared curve, and a leg with options on its rates reads the cap vols, so either is handed the view; any other leg keeps the one curve it always had.

Trait Implementations§

§

impl Clone for VanillaSwap

§

fn clone(&self) -> VanillaSwap

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for VanillaSwap

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl PartialEq for VanillaSwap

§

fn eq(&self, other: &VanillaSwap) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<R: Scalar> Priceable<R> for VanillaSwap

§

fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

Present value against the resolved market view. Read more
§

fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The par rate — the fixed rate at which the product is worth nothing. Read more
§

fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The par (breakeven) floating-leg spread. Zero for a product with no floating leg. Read more
§

impl PricingRiskFactors for VanillaSwap

§

fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>

Discounting and the index’s projection; every other tenor an interpolated stub reads — the first as the second projection, the rest in the projection basket; the currency’s cap vols when the floating leg carries options on its rates; and the pair of swap indices whose market correlation a CMS spread coupon on it reads.

§

impl Product for VanillaSwap

§

fn currency(&self) -> Currency

The currency the swap pays in: its own, or the settlement currency a non-deliverable swap converts every payment into.

§

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

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 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_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.
§

impl StructuralPartialEq for VanillaSwap

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.