24 const Handle<DefaultProbabilityTermStructure>& referenceCurve,
const std::vector<Time>& times,
25 const std::vector<Handle<Quote>>& spreads,
const Extrapolation extrapolation)
27 spreads_(spreads), data_(times.size(), 1.0), extrapolation_(extrapolation) {
28 QL_REQUIRE(
times_.size() > 1,
"at least two times required");
29 QL_REQUIRE(
times_.size() ==
spreads_.size(),
"size of time and quote vectors do not match");
30 QL_REQUIRE(
times_[0] == 0.0,
"First time must be 0, got " <<
times_[0]);
31 for (Size i = 0; i <
spreads_.size(); ++i) {
36 registerWith(Settings::instance().evaluationDate());
42 TermStructure::update();
46 for (Size i = 0; i <
times_.size(); ++i) {
48 "SpreadedSurvivalProbabilityTermStructure: quote at index " << i <<
" is empty");
50 QL_REQUIRE(
data_[i] > 0,
51 "SpreadedSurvivalProbabilityTermStructure: invalid value " <<
data_[i] <<
" at index " << i);
58 if (t <= this->
times_.back())
59 return referenceCurve_->survivalProbability(t) * (*interpolation_)(t,
true);
61 Real tMax = this->
times_.back();
62 Real dMax = this->
data_.back();
64 Real instFwdMax = -(*interpolation_).derivative(tMax) / dMax;
65 return referenceCurve_->survivalProbability(t) * dMax * std::exp(-instFwdMax * (t - tMax));
67 return referenceCurve_->survivalProbability(t) * std::pow(dMax, t / tMax);
std::vector< Time > times()
void performCalculations() const override
Calendar calendar() const override
Handle< DefaultProbabilityTermStructure > referenceCurve_
const Date & referenceDate() const override
std::vector< Time > times_
Handle< DefaultProbabilityTermStructure > referenceCurve() const
Extrapolation extrapolation_
SpreadedSurvivalProbabilityTermStructure(const Handle< DefaultProbabilityTermStructure > &referenceCurve, const std::vector< Time > ×, const std::vector< Handle< Quote > > &spreads, const Extrapolation extrapolation=Extrapolation::flatFwd)
times should be consistent with reference ts day counter
Natural settlementDays() const override
DayCounter dayCounter() const override
Probability survivalProbabilityImpl(Time) const override
Date maxDate() const override
std::vector< Handle< Quote > > spreads_
Time maxTime() const override
QuantLib::ext::shared_ptr< Interpolation > interpolation_
std::vector< Real > data_
spreaded default term structure