Struct NthToDefaultSwap
pub struct NthToDefaultSwap {
pub cds: CreditDefaultSwap,
pub entities: Vec<CreditCurveId>,
pub n: usize,
pub correlation: BasketCorrelation,
pub copula: Copula,
pub copula_dof: Option<CreditIndexId>,
}Expand description
An nth-to-default basket swap: premium accrues while fewer than n
constituents have defaulted; protection pays (1 − R̄)·N on the nth
default. The trigger survival Q(t) = P(N(t) < n) comes from the
one-factor Gaussian copula’s count distribution with each constituent’s
default probability read off its own survival curve — the first
product declaring a basket of entities.
Fields§
§cds: CreditDefaultSwapThe standard contract shape (schedule, coupon, notional, protection
start), labelled NTD:n/k — the label is not a credit entity.
entities: Vec<CreditCurveId>The constituents, in declaration order.
n: usizeThe trigger rank, 1..=k.
correlation: BasketCorrelationThe basket’s asset correlation: a contract term, or a market input.
copula: CopulaThe one-factor copula the count distribution is read under: Gaussian
unless with_student_t.
copula_dof: Option<CreditIndexId>The credit index whose market double-t degrees of freedom the basket
reads in place of copula, each with a risk row on the
correlation axis; see on_market_copula_dof.
Implementations§
§impl NthToDefaultSwap
impl NthToDefaultSwap
pub fn standard(
template: &CdsTemplate,
trade_date: NaiveDate,
entities: Vec<CreditCurveId>,
n: usize,
currency: Currency,
tenor_years: u32,
notional: f64,
spread: f64,
correlation: f64,
buys_protection: bool,
) -> Result<Self, CreditError>
pub fn standard( template: &CdsTemplate, trade_date: NaiveDate, entities: Vec<CreditCurveId>, n: usize, currency: Currency, tenor_years: u32, notional: f64, spread: f64, correlation: f64, buys_protection: bool, ) -> Result<Self, CreditError>
A standard basket swap.
§Errors
CreditError for an empty or duplicated basket, a rank outside
1..=k, or a correlation outside [0, 1).
pub fn standard_maturing(
template: &CdsTemplate,
trade_date: NaiveDate,
entities: Vec<CreditCurveId>,
n: usize,
currency: Currency,
maturity: NaiveDate,
notional: f64,
spread: f64,
correlation: f64,
buys_protection: bool,
) -> Result<Self, CreditError>
pub fn standard_maturing( template: &CdsTemplate, trade_date: NaiveDate, entities: Vec<CreditCurveId>, n: usize, currency: Currency, maturity: NaiveDate, notional: f64, spread: f64, correlation: f64, buys_protection: bool, ) -> Result<Self, CreditError>
standard with the maturity supplied directly.
The pair mirrors CreditDefaultSwap::standard and its twin. Every
basket check stays here, on the constructor that builds, so the
tenor-taking form cannot skip one.
§Errors
As standard.
pub fn with_fixed_recovery(self, recovery: f64) -> Self
pub fn with_fixed_recovery(self, recovery: f64) -> Self
Locks a contractual uniform recovery.
pub fn on_market_correlation(self, key: impl Into<String>) -> Self
pub fn on_market_correlation(self, key: impl Into<String>) -> Self
Reads the correlation from the market’s basket correlation under
key rather than the contract’s, so it carries a risk row on the
correlation axis. A market without it is refused by name.
pub fn on_market_copula_dof(self, index: CreditIndexId) -> Self
pub fn on_market_copula_dof(self, index: CreditIndexId) -> Self
Prices under the double-t copula on the degrees of freedom the market
marks for the credit index index
(MarketContext::with_copula_dof),
as a tranche’s on_market_copula_dof
does, so each carries a risk row on the correlation axis. A market
without them is refused by name.
pub fn with_student_t(
self,
factor_dof: f64,
idiosyncratic_dof: f64,
) -> Result<Self, CreditError>
pub fn with_student_t( self, factor_dof: f64, idiosyncratic_dof: f64, ) -> Result<Self, CreditError>
Prices under the double-t copula (Copula::StudentT): the factor
and each constituent Student-t with factor_dof and
idiosyncratic_dof degrees of freedom, scaled to unit variance, each
constituent’s threshold solved against its own default probability.
§Errors
CreditError::DegreesOfFreedom for a degree of freedom not in
(2, ∞).
§impl NthToDefaultSwap
impl NthToDefaultSwap
fn legs<R: Scalar>(
&self,
view: &PricingView<'_, R>,
) -> Result<(R, R), PricingError>
fn legs<R: Scalar>( &self, view: &PricingView<'_, R>, ) -> Result<(R, R), PricingError>
(premium annuity on the trigger survival, protection) on the
notional, with the uniform recovery applied.
Trait Implementations§
§impl Clone for NthToDefaultSwap
impl Clone for NthToDefaultSwap
§fn clone(&self) -> NthToDefaultSwap
fn clone(&self) -> NthToDefaultSwap
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 NthToDefaultSwap
impl Debug for NthToDefaultSwap
§impl PartialEq for NthToDefaultSwap
impl PartialEq for NthToDefaultSwap
§fn eq(&self, other: &NthToDefaultSwap) -> bool
fn eq(&self, other: &NthToDefaultSwap) -> bool
self and other values to be equal, and is used by ==.§impl<R: Scalar> Priceable<R> for NthToDefaultSwap
impl<R: Scalar> Priceable<R> for NthToDefaultSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
Buyer protection − premium, signed by side.
§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 NthToDefaultSwap
impl PricingRiskFactors for NthToDefaultSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
The collateral and the basket; the contract’s label is not an entity.
§impl Product for NthToDefaultSwap
impl Product for NthToDefaultSwap
§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.§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.