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: CurrencyThe swap’s currency.
index: StringThe floating side’s index, by registry code.
collateral: CollateralSpecWhat the swap is collateralised against.
effective: NaiveDateFirst accrual date.
maturity: NaiveDateThe single payment date of both sides.
notional: f64The notional.
fixed: LegThe 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: LegThe 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
impl ZeroCouponSwap
pub fn from_template(
template: &ZcsTemplate,
valuation: NaiveDate,
tenor: Period,
notional: f64,
fixed_rate: f64,
) -> Self
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
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
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
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
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
pub fn fixed_day_count(&self) -> DayCountFraction
pub fn fixed_compounding(&self) -> AccrualCompounding
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
pub fn fixed_year_fraction(&self) -> f64
The fixed side’s year fraction over the whole life.
§impl ZeroCouponSwap
impl ZeroCouponSwap
pub fn floating_amount<R: Scalar>(
&self,
view: &PricingView<'_, R>,
) -> Result<R, PricingError>
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
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
impl Clone for ZeroCouponSwap
§fn clone(&self) -> ZeroCouponSwap
fn clone(&self) -> ZeroCouponSwap
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 ZeroCouponSwap
impl Debug for ZeroCouponSwap
§impl PartialEq for ZeroCouponSwap
impl PartialEq for ZeroCouponSwap
§impl<R: Scalar> Priceable<R> for ZeroCouponSwap
impl<R: Scalar> Priceable<R> for ZeroCouponSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
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>
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>
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
impl PricingRiskFactors for ZeroCouponSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
§impl Product for ZeroCouponSwap
impl Product for ZeroCouponSwap
§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 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_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.