Skip to main content

ZeroCouponSwap

Struct ZeroCouponSwap 

pub struct ZeroCouponSwap {
    pub currency: Currency,
    pub index: String,
    pub collateral: CollateralSpec,
    pub effective: NaiveDate,
    pub maturity: NaiveDate,
    pub notional: f64,
    pub fixed: Leg,
    pub floating: Leg,
    pub side: f64,
}
Expand description

A zero-coupon swap: one terminal fixed accrual against a floating side that compounds its periods’ index-window forwards, both paid at maturity.

The floating side is a compiled leg of index-window coupons so that a reset already past reads the fixing store exactly as a vanilla leg’s would; the pricer folds their rates into one product rather than summing their amounts.

Fields§

§currency: Currency

The swap’s currency.

§index: String

The floating side’s index, by registry code.

§collateral: CollateralSpec

What the swap is collateralised against.

§effective: NaiveDate

First accrual date.

§maturity: NaiveDate

The single payment date of both sides.

§notional: f64

The notional.

§fixed: Leg

The fixed side: one coupon carrying the rate, accruing over the whole life into a single payment at maturity.

The rate is not held beside this. It is already on the coupon, and holding it twice invites the two to disagree — the same reason VanillaSwap keeps its rate only on its leg. Read it through fixed_rate.

§floating: Leg

The floating side’s compounding periods, one index-window coupon each, accumulating into a single payment at maturity.

§side: f64

+1 pays the fixed rate; −1 receives it.

Implementations§

§

impl ZeroCouponSwap

pub fn from_template( template: &ZcsTemplate, valuation: NaiveDate, tenor: Period, notional: f64, fixed_rate: f64, ) -> Self

A payer from its template: effective at the template’s spot, maturity one tenor later, periods at the template’s float frequency generated forward, each projecting over the index’s own window.

A payer pays fixed and receives floating, and its legs say so. The orientation lives on the legs as well as in side, so a caller reading legs() gets the trade rather than two receive-oriented schedules and a sign held elsewhere. It does not reach the valuation: npv reads each side through the leg’s own unsigned accumulated amount and applies side itself.

pub fn between( template: &ZcsTemplate, effective: NaiveDate, maturity: NaiveDate, notional: f64, fixed_rate: f64, ) -> Self

A zero-coupon swap between two stated dates.

The dates are taken as given rather than derived from a valuation and a tenor, so a contract whose start is written on a confirm is reproduced exactly and no convention moves it. This is the half from_template is the other of: that one derives the two dates and delegates here, so the derivation has one reading and the two forms cannot drift.

§Panics

If maturity is not after effective.

pub fn receiver(self) -> Self

The side receiving the fixed rate.

Flips the legs with side, so the two cannot come apart: a receiver receives fixed and pays floating, and each leg is on the side it is actually on.

pub fn with_fixed_rate(self, fixed_rate: f64) -> Self

Sets the fixed rate, by rebuilding the one coupon that carries it.

pub fn fixed_rate(&self) -> f64

The fixed rate, read off the coupon that carries it.

§Panics

If the fixed leg is not the one fixed coupon this type builds, which no constructor here produces.

pub fn fixed_day_count(&self) -> DayCountFraction

The fixed side’s day count, read off the coupon that accrues on it.

§Panics

As fixed_rate.

pub fn fixed_compounding(&self) -> AccrualCompounding

How the fixed rate accrues over the life, read off the leg’s own accumulation.

§Panics

If the fixed leg does not accrue a rate, which no constructor here produces.

pub fn fixed_year_fraction(&self) -> f64

The fixed side’s year fraction over the whole life.

§

impl ZeroCouponSwap

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

The floating side’s terminal amount, N · (∏(1 + r_i·τ_i) − 1) over the periods’ index-window rates — published fixings where a reset has passed, projected forwards otherwise — with τ_i each period’s accrual. No telescoping: the index windows do not tile the accruals, so the product is not a discount-factor ratio.

§Errors

Whatever the projection curve or the fixing store reports.

pub fn fixed_amount(&self, rate: f64) -> f64

The fixed side’s terminal amount at rate: N · (growth − 1) under the swap’s compounding over its whole life.

At the swap’s own rate this is the fixed leg’s accumulated amount, and it is that leg that computes it. A different rate is the par solve asking what the side would be worth struck elsewhere, which rebuilds the one coupon that carries it rather than recomputing the growth here.

§Panics

If the fixed leg is not the one fixed coupon this type builds, which no constructor here produces.

Trait Implementations§

§

impl Clone for ZeroCouponSwap

§

fn clone(&self) -> ZeroCouponSwap

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 ZeroCouponSwap

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for ZeroCouponSwap

§

fn eq(&self, other: &ZeroCouponSwap) -> 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 ZeroCouponSwap

§

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

side · (float − fixed) · DF(maturity); nothing once the payment date has passed.

§

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

The par zero rate: the single rate whose terminal accrual matches the floating side, inverted closed-form from the growth the fixed side would need, 1 + float / N — both sides pay on the same date, so the discount factor cancels.

§

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

Unsupported: a margin inside a compounding side enters as ∏(1 + (f_i + s)·τ_i) — there is no annuity to divide by, and the breakeven is a root, not a ratio. A linearised spread would be a plausible number with no contract behind it.

§

impl PricingRiskFactors for ZeroCouponSwap

§

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

The market data this product is priced against. Read more
§

impl Product for ZeroCouponSwap

§

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 currency(&self) -> Currency

The currency the product pays in. An FX product values in its quote currency; a book converts.
§

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 ZeroCouponSwap

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.