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: LegThe fixed leg.
floating: LegThe floating leg.
currency: CurrencyThe swap’s currency.
index: StringThe projection index the floating leg resets against.
collateral: CollateralSpecWhat 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
impl VanillaSwap
pub fn new(
fixed: Leg,
floating: Leg,
currency: Currency,
index: impl Into<String>,
collateral: CollateralSpec,
) -> Self
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]
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>
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
pub fn with_stated_dates( self, effective: NaiveDate, termination: NaiveDate, ) -> Self
This swap stating the unadjusted dates its schedule was generated from.
§impl VanillaSwap
impl VanillaSwap
fn floating_curves<'v, R: Scalar>(
&self,
view: &'v PricingView<'_, R>,
fwd: &'v OneCurve<'v, R>,
) -> &'v dyn CurveByIndex<R>
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
impl Clone for VanillaSwap
§fn clone(&self) -> VanillaSwap
fn clone(&self) -> VanillaSwap
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 VanillaSwap
impl Debug for VanillaSwap
§impl PartialEq for VanillaSwap
impl PartialEq for VanillaSwap
§impl<R: Scalar> Priceable<R> for VanillaSwap
impl<R: Scalar> Priceable<R> for VanillaSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
§fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn par_rate(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
§fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
§impl PricingRiskFactors for VanillaSwap
impl PricingRiskFactors for VanillaSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
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
impl Product for VanillaSwap
§fn currency(&self) -> Currency
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>
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.§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_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.