Skip to main content

SpreadCdsHelper

Struct SpreadCdsHelper 

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

A spread-quoted CDS as a credit bootstrap helper (SpreadCdsHelper, defaultprobabilityhelpers.hpp:128).

The helper prices a par CDS on its own schedule against the curve being bootstrapped and reports that contract’s fair spread as implied_quote; the bootstrap drives quoted spread - fair spread to zero.

The C++ CdsHelper base (defaultprobabilityhelpers.hpp:47-126) has no separate type here. It exists in C++ only to share state and initializeDates with UpfrontCdsHelper, and that sibling is deferred (#676), so its state and initializeDates live directly in this struct. Porting UpfrontCdsHelper means factoring out the fields below plus initialize_dates and set_term_structure, leaving only reset_engine and implied_quote per subclass.

Implementations§

Source§

impl SpreadCdsHelper

Source

pub fn new( running_spread: Handle<dyn Quote>, tenor: Period, settlement_days: Integer, calendar: Calendar, frequency: Frequency, payment_convention: BusinessDayConvention, rule: DateGeneration, day_counter: DayCounter, recovery_rate: Real, discount_curve: Handle<dyn YieldTermStructure>, settings: Shared<Settings<Date>>, ) -> QlResult<Shared<SpreadCdsHelper>>

A helper on the C++ default terms (defaultprobabilityhelpers.cpp:109).

The C++ quote is a std::variant<Rate, Handle<Quote>> (hpp:129); a quoted spread takes the Rate arm here as make_quote_handle(spread).handle().

§Errors

As with_terms.

Source

pub fn with_terms( running_spread: Handle<dyn Quote>, tenor: Period, settlement_days: Integer, calendar: Calendar, frequency: Frequency, payment_convention: BusinessDayConvention, rule: DateGeneration, day_counter: DayCounter, recovery_rate: Real, discount_curve: Handle<dyn YieldTermStructure>, terms: CdsHelperTerms, settings: Shared<Settings<Date>>, ) -> QlResult<Shared<SpreadCdsHelper>>

A helper on the given terms (defaultprobabilityhelpers.cpp:40-58).

The helper observes its quote and its discount curve (the constructor’s registerWith(discountCurve), cpp:57) and tracks the evaluation date, rebuilding its schedule and its contract whenever that date moves.

§Errors

Rejects the three CDS date-generation rules. Their maturity comes from cdsMaturity (cpp:87), which is not ported, and taking the other arm for them would silently produce a schedule ending on the wrong date; that branch is deferred within EPIC Credit (#676).

Source

pub fn protection_start(&self) -> Date

The date protection starts, settlement_days past the evaluation date (cpp:79).

Trait Implementations§

Source§

impl AsObservable for SpreadCdsHelper

Source§

fn observable(&self) -> &Observable

Access to the embedded observable for registering observers.
Source§

impl DefaultProbabilityHelper for SpreadCdsHelper

Source§

fn implied_quote(&self) -> QlResult<Real>

The contract’s fair spread (impliedQuote, cpp:132-135).

The recalculation is forced rather than left to the cache: the helper weak-links the curve handle the engine prices over, so a node the bootstrap has just moved does not notify the contract, and a plain fair_spread would answer from the previous iteration’s results.

Source§

fn set_term_structure( &self, term_structure: &Shared<dyn DefaultProbabilityTermStructure>, )

Records the curve, hands it to the engine, and rebuilds the contract (setTermStructure, cpp:60-68).

The engine’s handle is linked weakly, the port of the C++ linkTo(..., false) at cpp:63-65: the curve owns this helper, which owns the contract, which owns the engine, and a strong link would close that ring.

Source§

fn base(&self) -> &DefaultProbabilityHelperBase

The embedded shared state.
Source§

fn quote(&self) -> &Handle<dyn Quote>

The market quote the helper fits the curve to.
Source§

fn quote_error(&self) -> QlResult<Real>

The bootstrap’s root: market quote minus implied quote, driven to zero.
Source§

fn earliest_date(&self) -> Date

The earliest date data are needed at.
Source§

fn maturity_date(&self) -> Date

The instrument’s maturity date.
Source§

fn latest_relevant_date(&self) -> Date

The latest date data are needed at.
Source§

fn pillar_date(&self) -> Date

The pillar date, at which the curve node this helper sets sits.
Source§

fn latest_date(&self) -> Date

The latest date, equal to the pillar date.
Source§

impl RelativeDateDefaultProbabilityHelper for SpreadCdsHelper

Source§

fn initialize_dates(&self)

Rebuilds the schedule off the current evaluation date (initializeDates, cpp:75-108).

Protection starts settlement_days past the evaluation date and, absent an explicit start, the schedule starts there too, rolled to a business day. The maturity is the tenor past that same reference date - the cdsMaturity arm above it (cpp:86-88) covers only the three CDS rules, which the constructor rejects; TwentiethIMM takes this arm.

The earliest date is the schedule’s first date and the latest its last, rolled. C++ then adds a day under the ISDA model (cpp:105-106); the midpoint model, the only one ported, does not.

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.