Skip to main content

CreditDefaultSwap

Struct CreditDefaultSwap 

Source
pub struct CreditDefaultSwap { /* private fields */ }
Expand description

A credit-default swap quoted as a running spread.

One side pays the premium leg and receives the protection payment, the other the reverse; which way round is side.

Implementations§

Source§

impl CreditDefaultSwap

Source

pub fn new( side: ProtectionSide, notional: Real, spread: Rate, schedule: Schedule, payment_convention: BusinessDayConvention, day_counter: DayCounter, settles_accrual: bool, pays_at_default_time: bool, settings: Shared<Settings<Date>>, ) -> QlResult<CreditDefaultSwap>

A contract on the C++ default terms, settling its accrual and paying at default time as settles_accrual and pays_at_default_time say (creditdefaultswap.cpp:39-60).

The remaining terms take their C++ defaults; with_terms gives them.

§Errors

As with_terms.

Source

pub fn with_terms( side: ProtectionSide, notional: Real, spread: Rate, schedule: Schedule, payment_convention: BusinessDayConvention, day_counter: DayCounter, terms: CdsTerms, settings: Shared<Settings<Date>>, ) -> QlResult<CreditDefaultSwap>

A contract on the given terms (creditdefaultswap.cpp:39-60 and its init, :87-176).

§Errors

Errors on an empty schedule, on a protection start after the first accrual date under a pre-Big-Bang date-generation rule, on a cash settlement date before the protection start, and on the deferred accrual-rebate case where the trade date falls on or after the first accrual date. Propagates the premium leg’s own preconditions.

Source

pub fn side(&self) -> ProtectionSide

Which side of the protection this contract holds.

Source

pub fn notional(&self) -> Real

The notional the protection covers.

Source

pub fn running_spread(&self) -> Rate

The running spread the premium leg pays.

Source

pub fn upfront(&self) -> Option<Rate>

The upfront, in fractional units.

Always None here: only the deferred upfront-quoted constructor sets it (creditdefaultswap.cpp:78).

Source

pub fn settles_accrual(&self) -> bool

Whether the accrued coupon is due on a default.

Source

pub fn pays_at_default_time(&self) -> bool

Whether a default pays at default time.

Source

pub fn claim(&self) -> &Shared<dyn Claim>

What a default pays out.

Source

pub fn coupons(&self) -> &Leg

The premium leg.

Source

pub fn protection_start_date(&self) -> Date

The first date a default triggers the contract.

Source

pub fn maturity(&self) -> Date

The schedule’s last date.

Source

pub fn upfront_payment(&self) -> &Shared<SimpleCashFlow>

The zero-amount upfront payment, due on the cash settlement date.

Source

pub fn accrual_rebate(&self) -> Option<&Shared<SimpleCashFlow>>

The accrual rebate, when the contract carries one.

Source

pub fn rebates_accrual(&self) -> bool

Whether the protection seller rebates the accrued current coupon (creditdefaultswap.hpp:186).

Source

pub fn trade_date(&self) -> Date

The contract’s trade date.

Source

pub fn cash_settlement_days(&self) -> Natural

The business days from the trade date to cash settlement.

Source

pub fn fair_spread(&mut self) -> QlResult<Rate>

The spread that prices the contract at zero (creditdefaultswap.cpp:266-271).

§Errors

The calculation must succeed and the engine must have provided the value; an engine pricing a worthless premium leg does not (midpointcdsengine.cpp:156-157).

Source

pub fn fair_upfront(&mut self) -> QlResult<Rate>

The upfront that prices the contract at zero (creditdefaultswap.cpp:259-264).

§Errors

As fair_spread.

Source

pub fn coupon_leg_bps(&mut self) -> QlResult<Real>

The premium leg’s sensitivity to a one-basis-point spread move (creditdefaultswap.cpp:273-278).

§Errors

As fair_spread.

Source

pub fn coupon_leg_npv(&mut self) -> QlResult<Real>

The premium leg’s NPV (creditdefaultswap.cpp:280-285).

§Errors

As fair_spread.

Source

pub fn default_leg_npv(&mut self) -> QlResult<Real>

The protection leg’s NPV (creditdefaultswap.cpp:287-292).

§Errors

As fair_spread.

Source

pub fn upfront_npv(&mut self) -> QlResult<Real>

The upfront payment’s NPV (creditdefaultswap.cpp:294-299).

§Errors

As fair_spread.

Source

pub fn upfront_bps(&mut self) -> QlResult<Real>

The upfront payment’s sensitivity to a one-basis-point upfront move (creditdefaultswap.cpp:301-306).

§Errors

As fair_spread.

Source

pub fn accrual_rebate_npv(&mut self) -> QlResult<Real>

The accrual rebate’s NPV (creditdefaultswap.cpp:308-313).

§Errors

As fair_spread, and additionally on an expired contract, which C++ leaves reading an uninitialised member.

Trait Implementations§

Source§

impl Instrument for CreditDefaultSwap

Source§

fn is_expired(&self) -> QlResult<bool>

creditdefaultswap.cpp:207-213: expired once every premium flow has occurred.

Source§

fn setup_arguments(&self, arguments: &mut dyn Arguments) -> QlResult<()>

creditdefaultswap.cpp:222-239.

Source§

fn setup_expired(&mut self)

creditdefaultswap.cpp:215-220, which zeroes seven of the eight results and leaves accrualRebateNPV_ as it found it.

Source§

fn fetch_results(&mut self, results: &dyn Results) -> QlResult<()>

creditdefaultswap.cpp:242-257.

Source§

fn base(&self) -> &InstrumentBase

The embedded base state.
Source§

fn base_mut(&mut self) -> &mut InstrumentBase

Mutable access to the embedded base state.
Source§

fn perform_calculations(&mut self) -> QlResult<()>

Runs the engine protocol (performCalculations): reset, fill and validate the arguments, calculate, fetch the results. Override only when pricing without an engine. Read more
Source§

fn calculate(&mut self) -> QlResult<()>

Recomputes the results if the cache is stale, short-circuiting expired instruments (Instrument::calculate). Read more
Source§

fn recalculate(&mut self) -> QlResult<()>

Forces a recalculation and notifies observers even on failure (LazyObject::recalculate, inherited by every C++ instrument; goes through the virtual calculate, so expired instruments short-circuit).
Source§

fn npv(&mut self) -> QlResult<Real>

The net present value of the instrument (NPV()).
Source§

fn error_estimate(&mut self) -> QlResult<Real>

The error estimate on the NPV, when available (errorEstimate()).
Source§

fn valuation_date(&mut self) -> QlResult<Date>

The date the net present value refers to (valuationDate()).
Source§

fn result<T: Any + Clone>(&mut self, tag: &str) -> QlResult<T>
where Self: Sized,

An additional named result returned by the engine (result<T>(tag)).
Source§

fn additional_results(&mut self) -> QlResult<&BTreeMap<String, Shared<dyn Any>>>

All additional results returned by the engine (additionalResults()).

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