Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MultiSectionDefaultCurve Class Reference

multi section default ts More...

#include <qle/termstructures/multisectiondefaultcurve.hpp>

+ Inheritance diagram for MultiSectionDefaultCurve:
+ Collaboration diagram for MultiSectionDefaultCurve:

Public Member Functions

 MultiSectionDefaultCurve (const std::vector< Handle< DefaultProbabilityTermStructure > > &sourceCurves, const std::vector< Handle< Quote > > recoveryRates, const std::vector< Date > &switchDates, const Handle< Quote > recoveryRate, const DayCounter &dayCounter, const bool extrapolate)
 
Date maxDate () const override
 
const Date & referenceDate () const override
 

Protected Member Functions

Real survivalProbabilityImpl (Time t) const override
 
void update () override
 

Protected Attributes

const std::vector< Handle< DefaultProbabilityTermStructure > > sourceCurves_
 
const std::vector< Handle< Quote > > recoveryRates_
 
const std::vector< Date > switchDates_
 
const Handle< Quote > recoveryRate_
 
std::vector< Time > switchTimes_
 

Detailed Description

multi section default ts

the instantaneous hazard rate is defined by the ith source curve for dates before the ith switch date and after the (i-1)th switch date; all source curves must be consistently floating or fixed and have the same reference date always; the day counter of all source curves should coincide with the dc of this curve

Definition at line 37 of file multisectiondefaultcurve.hpp.

Constructor & Destructor Documentation

◆ MultiSectionDefaultCurve()

MultiSectionDefaultCurve ( const std::vector< Handle< DefaultProbabilityTermStructure > > &  sourceCurves,
const std::vector< Handle< Quote > >  recoveryRates,
const std::vector< Date > &  switchDates,
const Handle< Quote >  recoveryRate,
const DayCounter &  dayCounter,
const bool  extrapolate 
)

Definition at line 39 of file multisectiondefaultcurve.hpp.

42 : SurvivalProbabilityStructure(dayCounter), sourceCurves_(sourceCurves), recoveryRates_(recoveryRates),
43 switchDates_(switchDates), recoveryRate_(recoveryRate) {
44 QL_REQUIRE(!sourceCurves_.empty(), "no source curves given");
45 QL_REQUIRE(sourceCurves_.size() - 1 == switchDates_.size(),
46 "source curve size (" << sourceCurves_.size() << ") minus 1 and switch dates size ("
47 << switchDates_.size() << ") do not match");
48 QL_REQUIRE(sourceCurves_.size() == recoveryRates_.size(),
49 "source curve size (" << sourceCurves_.size() << ") must match recovery rates size ("
50 << recoveryRates_.size() << ")");
51 switchTimes_.resize(switchDates_.size());
52 for (Size i = 1; i < switchDates_.size(); ++i) {
53 QL_REQUIRE(switchDates_[i] > switchDates_[i - 1], "switch dates must be strictly ascending, got "
54 << switchDates_[i - 1] << ", " << switchDates_[i]
55 << " at indices " << i - 1 << ", " << i);
56 }
57 for (auto const& s : sourceCurves_)
58 registerWith(s);
59 for (auto const& r : recoveryRates_)
60 registerWith(r);
61 enableExtrapolation(extrapolate);
62 update();
63 }
const std::vector< Handle< DefaultProbabilityTermStructure > > sourceCurves_
const std::vector< Handle< Quote > > recoveryRates_
+ Here is the call graph for this function:

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 65 of file multisectiondefaultcurve.hpp.

65{ return sourceCurves_.back()->maxDate(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 66 of file multisectiondefaultcurve.hpp.

66{ return sourceCurves_.front()->referenceDate(); }

◆ survivalProbabilityImpl()

Real survivalProbabilityImpl ( Time  t) const
overrideprotected

Definition at line 69 of file multisectiondefaultcurve.hpp.

69 {
70 Size idx = std::lower_bound(switchTimes_.begin(), switchTimes_.end(), t,
71 [](const Real s, const Real t) { return s < t && !QuantLib::close_enough(s, t); }) -
72 switchTimes_.begin();
73 QL_REQUIRE(idx < sourceCurves_.size(), "internal error: source curve index is "
74 << idx << ", number of source curves is " << sourceCurves_.size());
75 Real prob = 1.0;
76 for (Size i = 0; i < idx; ++i) {
77 Real t0 = i == 0 ? 0.0 : std::max(switchTimes_[i - 1], 0.0);
78 Real t1 = switchTimes_[i];
79 if (t1 > 0.0)
80 prob *= std::pow(sourceCurves_[i]->survivalProbability(t1) / sourceCurves_[i]->survivalProbability(t0),
81 1.0 - recoveryRates_[i]->value());
82 }
83 // we know that t > 0
84 Real t0 = idx == 0 ? 0.0 : std::max(switchTimes_[idx - 1], 0.0);
85 prob *= std::pow(sourceCurves_[idx]->survivalProbability(t) / sourceCurves_[idx]->survivalProbability(t0),
86 1.0 - recoveryRates_[idx]->value());
87 prob = std::pow(prob, 1.0 / (1.0 - recoveryRate_->value()));
88 return prob;
89 }

◆ update()

void update ( )
overrideprotected

Definition at line 90 of file multisectiondefaultcurve.hpp.

90 {
91 SurvivalProbabilityStructure::update();
92 for (Size i = 0; i < switchDates_.size(); ++i)
93 switchTimes_[i] = timeFromReference(switchDates_[i]);
94 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ sourceCurves_

const std::vector<Handle<DefaultProbabilityTermStructure> > sourceCurves_
protected

Definition at line 95 of file multisectiondefaultcurve.hpp.

◆ recoveryRates_

const std::vector<Handle<Quote> > recoveryRates_
protected

Definition at line 96 of file multisectiondefaultcurve.hpp.

◆ switchDates_

const std::vector<Date> switchDates_
protected

Definition at line 97 of file multisectiondefaultcurve.hpp.

◆ recoveryRate_

const Handle<Quote> recoveryRate_
protected

Definition at line 98 of file multisectiondefaultcurve.hpp.

◆ switchTimes_

std::vector<Time> switchTimes_
mutableprotected

Definition at line 99 of file multisectiondefaultcurve.hpp.