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
impl CreditDefaultSwap
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn side(&self) -> ProtectionSide
pub fn side(&self) -> ProtectionSide
Which side of the protection this contract holds.
Sourcepub fn running_spread(&self) -> Rate
pub fn running_spread(&self) -> Rate
The running spread the premium leg pays.
Sourcepub fn upfront(&self) -> Option<Rate>
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).
Sourcepub fn settles_accrual(&self) -> bool
pub fn settles_accrual(&self) -> bool
Whether the accrued coupon is due on a default.
Sourcepub fn pays_at_default_time(&self) -> bool
pub fn pays_at_default_time(&self) -> bool
Whether a default pays at default time.
Sourcepub fn protection_start_date(&self) -> Date
pub fn protection_start_date(&self) -> Date
The first date a default triggers the contract.
Sourcepub fn upfront_payment(&self) -> &Shared<SimpleCashFlow>
pub fn upfront_payment(&self) -> &Shared<SimpleCashFlow>
The zero-amount upfront payment, due on the cash settlement date.
Sourcepub fn accrual_rebate(&self) -> Option<&Shared<SimpleCashFlow>>
pub fn accrual_rebate(&self) -> Option<&Shared<SimpleCashFlow>>
The accrual rebate, when the contract carries one.
Sourcepub fn rebates_accrual(&self) -> bool
pub fn rebates_accrual(&self) -> bool
Whether the protection seller rebates the accrued current coupon
(creditdefaultswap.hpp:186).
Sourcepub fn trade_date(&self) -> Date
pub fn trade_date(&self) -> Date
The contract’s trade date.
Sourcepub fn cash_settlement_days(&self) -> Natural
pub fn cash_settlement_days(&self) -> Natural
The business days from the trade date to cash settlement.
Sourcepub fn fair_spread(&mut self) -> QlResult<Rate>
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).
Sourcepub fn fair_upfront(&mut self) -> QlResult<Rate>
pub fn fair_upfront(&mut self) -> QlResult<Rate>
The upfront that prices the contract at zero
(creditdefaultswap.cpp:259-264).
§Errors
As fair_spread.
Sourcepub fn coupon_leg_bps(&mut self) -> QlResult<Real>
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.
Sourcepub fn coupon_leg_npv(&mut self) -> QlResult<Real>
pub fn coupon_leg_npv(&mut self) -> QlResult<Real>
Sourcepub fn default_leg_npv(&mut self) -> QlResult<Real>
pub fn default_leg_npv(&mut self) -> QlResult<Real>
Sourcepub fn upfront_npv(&mut self) -> QlResult<Real>
pub fn upfront_npv(&mut self) -> QlResult<Real>
Sourcepub fn upfront_bps(&mut self) -> QlResult<Real>
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.
Sourcepub fn accrual_rebate_npv(&mut self) -> QlResult<Real>
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
impl Instrument for CreditDefaultSwap
Source§fn is_expired(&self) -> QlResult<bool>
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<()>
fn setup_arguments(&self, arguments: &mut dyn Arguments) -> QlResult<()>
creditdefaultswap.cpp:222-239.
Source§fn setup_expired(&mut self)
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<()>
fn fetch_results(&mut self, results: &dyn Results) -> QlResult<()>
creditdefaultswap.cpp:242-257.
Source§fn base(&self) -> &InstrumentBase
fn base(&self) -> &InstrumentBase
Source§fn base_mut(&mut self) -> &mut InstrumentBase
fn base_mut(&mut self) -> &mut InstrumentBase
Source§fn perform_calculations(&mut self) -> QlResult<()>
fn perform_calculations(&mut self) -> QlResult<()>
performCalculations): reset, fill and
validate the arguments, calculate, fetch the results. Override only
when pricing without an engine. Read moreSource§fn calculate(&mut self) -> QlResult<()>
fn calculate(&mut self) -> QlResult<()>
Instrument::calculate). Read moreSource§fn recalculate(&mut self) -> QlResult<()>
fn recalculate(&mut self) -> QlResult<()>
LazyObject::recalculate, inherited by every C++ instrument; goes
through the virtual calculate, so expired instruments short-circuit).Source§fn error_estimate(&mut self) -> QlResult<Real>
fn error_estimate(&mut self) -> QlResult<Real>
errorEstimate()).Source§fn valuation_date(&mut self) -> QlResult<Date>
fn valuation_date(&mut self) -> QlResult<Date>
valuationDate()).