34#include <ql/math/interpolations/backwardflatinterpolation.hpp>
35#include <ql/math/interpolations/loginterpolation.hpp>
36#include <ql/termstructures/credit/defaultprobabilityhelpers.hpp>
37#include <ql/termstructures/credit/flathazardrate.hpp>
38#include <ql/time/daycounters/actual365fixed.hpp>
51 QuoteData() :
value(Null<Real>()), runningSpread(Null<Real>()) {}
53 QuoteData(
const Period& t, Real v,
string s,
string c,
string d, Real rs = Null<Real>())
54 : term(t),
value(v), seniority(s), ccy(c), docClause(d), runningSpread(rs) {}
64bool operator<(
const QuoteData& lhs,
const QuoteData& rhs) {
return lhs.term < rhs.term; }
66void addQuote(set<QuoteData>& quotes,
const string& configId,
const string&
name,
const Period& tenor, Real
value,
67 string seniority,
string ccy,
string docClause, Real runningSpread = Null<Real>()) {
70 auto r = quotes.insert(QuoteData(tenor,
value, seniority, ccy, docClause, runningSpread));
71 QL_REQUIRE(r.second,
"duplicate term in quotes found (" << tenor <<
") while loading default curve " << configId);
72 TLOG(
"Loaded quote " <<
name <<
" for default curve " << configId);
76 const Date& asof,
const Loader& loader) {
81 LOG(
"Loading regex quotes for default curve " << configId);
84 set<QuoteData> result;
86 std::ostringstream ss1;
87 ss1 << MDIT::CDS <<
"/*";
89 auto data1 = loader.
get(w1, asof);
91 std::ostringstream ss2;
92 ss2 << MDIT::HAZARD_RATE <<
"/*";
94 auto data2 = loader.
get(w2, asof);
98 for (
const auto& md : data1) {
100 QL_REQUIRE(md->asofDate() == asof,
"MarketDatum asofDate '" << md->asofDate() <<
"' <> asof '" << asof <<
"'");
102 auto mdit = md->instrumentType();
103 auto mdqt = md->quoteType();
106 if (type == DCCT::SpreadCDS && mdit == MDIT::CDS &&
107 (mdqt == MDQT::CREDIT_SPREAD || mdqt == MDQT::CONV_CREDIT_SPREAD)) {
109 auto q = QuantLib::ext::dynamic_pointer_cast<CdsQuote>(md);
110 QL_REQUIRE(q,
"Internal error: could not downcast MarketDatum '" << md->name() <<
"' to CdsQuote");
112 addQuote(result, configId, q->name(), q->term(), q->quote()->value(), q->seniority(), q->ccy(),
113 q->docClause(), q->runningSpread());
116 }
else if (type == DCCT::Price && (mdit == MDIT::CDS && mdqt == MDQT::PRICE)) {
118 auto q = QuantLib::ext::dynamic_pointer_cast<CdsQuote>(md);
119 QL_REQUIRE(q,
"Internal error: could not downcast MarketDatum '" << md->name() <<
"' to CdsQuote");
121 addQuote(result, configId, q->name(), q->term(), q->quote()->value(), q->seniority(), q->ccy(),
122 q->docClause(), q->runningSpread());
125 }
else if (type == DCCT::HazardRate && (mdit == MDIT::HAZARD_RATE && mdqt == MDQT::RATE)) {
127 auto q = QuantLib::ext::dynamic_pointer_cast<HazardRateQuote>(md);
128 QL_REQUIRE(q,
"Internal error: could not downcast MarketDatum '" << md->name() <<
"' to HazardRateQuote");
130 addQuote(result, configId, q->name(), q->term(), q->quote()->value(), q->seniority(), q->ccy(),
139 std::set<string> seniorities, ccys, docClauses;
140 for (
auto const& q : result) {
141 if (!q.seniority.empty())
142 seniorities.insert(q.seniority);
145 if (!q.docClause.empty())
146 docClauses.insert(q.docClause);
149 QL_REQUIRE(seniorities.size() < 2,
"More than one seniority found in wildcard quotes.");
150 QL_REQUIRE(ccys.size() < 2,
"More than one seniority found in wildcard quotes.");
151 QL_REQUIRE(docClauses.size() < 2,
"More than one seniority found in wildcard quotes.");
155 if (type != DCCT::SpreadCDS && type != DCCT::Price) {
156 QL_REQUIRE(!result.empty(),
"No market points found for curve config " << configId);
159 LOG(
"DefaultCurve " << configId <<
" loaded and using " << result.size() <<
" quotes.");
164set<QuoteData> getExplicitQuotes(
const vector<pair<string, bool>>& quotes,
const string& configId,
168 LOG(
"Loading explicit quotes for default curve " << configId);
170 set<QuoteData> result;
171 for (
const auto& p : quotes) {
172 if (QuantLib::ext::shared_ptr<MarketDatum> md = loader.
get(p, asof)) {
173 if (type == DCCT::SpreadCDS || type == DCCT::Price) {
174 auto q = QuantLib::ext::dynamic_pointer_cast<CdsQuote>(md);
175 QL_REQUIRE(q,
"Quote " << p.first <<
" for config " << configId <<
" should be a CdsQuote");
176 addQuote(result, configId, q->name(), q->term(), q->quote()->value(), q->seniority(), q->ccy(),
177 q->docClause(), q->runningSpread());
179 auto q = QuantLib::ext::dynamic_pointer_cast<HazardRateQuote>(md);
180 QL_REQUIRE(q,
"Quote " << p.first <<
" for config " << configId <<
" should be a HazardRateQuote");
181 addQuote(result, configId, q->name(), q->term(), q->quote()->value(), q->seniority(), q->ccy(),
189 if (type != DCCT::SpreadCDS && type != DCCT::Price) {
190 QL_REQUIRE(!result.empty(),
"No market points found for curve config " << configId);
193 LOG(
"DefaultCurve " << configId <<
" using " << result.size() <<
" default quotes of " << quotes.size()
194 <<
" requested quotes.");
200 const Date& asof,
const Loader& loader) {
203 auto type = config.
type();
204 QL_REQUIRE(type == DCCT::SpreadCDS || type == DCCT::Price || type == DCCT::HazardRate,
205 "getConfiguredQuotes expects a curve type of SpreadCDS, Price or HazardRate.");
206 QL_REQUIRE(!config.
cdsQuotes().empty(),
"No quotes configured for curve " << curveID);
209 std::vector<std::string> tmp;
210 std::transform(config.
cdsQuotes().begin(), config.
cdsQuotes().end(), std::back_inserter(tmp),
211 [](
const std::pair<std::string, bool>& p) { return p.first; });
215 return getRegexQuotes(*wildcard, curveID, config.
type(), asof, loader);
217 return getExplicitQuotes(config.
cdsQuotes(), curveID, config.
type(), asof, loader);
228 map<
string, QuantLib::ext::shared_ptr<YieldCurve>>& yieldCurves,
229 map<
string, QuantLib::ext::shared_ptr<DefaultCurve>>& defaultCurves) {
233 for (
auto const& config : configs->configs()) {
241 for (
auto const& q : loader.
get(wc, asof)) {
244 "There is more than one recovery rate matching the pattern '" << wc.
pattern()
251 "There is no market data for the requested recovery rate "
258 switch (config.second.
type()) {
261 buildCdsCurve(configs->curveID(), config.second, asof,
spec, loader, yieldCurves);
279 QL_FAIL(
"The DefaultCurveConfig type " <<
static_cast<int>(config.second.
type())
280 <<
" was not recognised");
284 }
catch (exception& e) {
285 std::ostringstream message;
286 message <<
"build attempt failed for " << configs->curveID() <<
" using config with priority "
287 << config.first <<
": " << e.what();
291 errors += message.str();
294 QL_REQUIRE(built,
"default curve building failed for " <<
spec.
curveConfigID() <<
": " << errors);
299 map<
string, QuantLib::ext::shared_ptr<YieldCurve>>& yieldCurves) {
301 LOG(
"Start building default curve of type SpreadCDS for curve " << curveID);
305 "DefaultCurve::buildCdsCurve expected a default curve configuration with type SpreadCDS/Price");
306 QL_REQUIRE(
recoveryRate_ != Null<Real>(),
"DefaultCurve: recovery rate needed to build SpreadCDS curve");
309 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
311 QuantLib::ext::shared_ptr<CdsConvention> cdsConv =
312 QuantLib::ext::dynamic_pointer_cast<CdsConvention>(conventions->get(config.
conventionID()));
313 QL_REQUIRE(cdsConv,
"SpreadCDS curves require CDS convention");
317 QL_REQUIRE(it != yieldCurves.end(),
"The discount curve, " << config.
discountCurveID()
318 <<
", required in the building of the curve, "
319 <<
spec.
name() <<
", was not found.");
320 Handle<YieldTermStructure> discountCurve = it->second->handle();
323 set<QuoteData> quotes = getConfiguredQuotes(curveID, config, asof, loader);
329 refData.
tenor = Period(cdsConv->frequency());
330 refData.
calendar = cdsConv->calendar();
331 refData.
convention = cdsConv->paymentConvention();
333 refData.
rule = cdsConv->rule();
346 vector<Date> dates{asof, asof + 1 * Years, asof + 10 * Years};
347 vector<Real> survivalProbs{1.0, 1e-16, 1e-18};
348 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(
349 Handle<DefaultProbabilityTermStructure>(
351 dates, survivalProbs, config.
dayCounter(), Calendar(), std::vector<Handle<Quote>>(),
352 std::vector<Date>(), LogLinear())),
353 discountCurve, Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(
recoveryRate_)), refData);
354 curve_->curve()->enableExtrapolation();
355 WLOG(
"DefaultCurve: recovery rate found but no CDS quotes for "
356 << curveID <<
" and "
357 <<
"ImplyDefaultFromMarket is true. Curve built that gives default immediately.");
361 QL_REQUIRE(!quotes.empty(),
"No market points found for CDS curve config " << curveID);
365 vector<QuantLib::ext::shared_ptr<QuantExt::DefaultProbabilityHelper>> helpers;
366 std::map<QuantLib::Date, QuantLib::Period> helperQuoteTerms;
367 Real runningSpread = Null<Real>();
368 QuantExt::CreditDefaultSwap::ProtectionPaymentTime ppt = cdsConv->paysAtDefaultTime()
369 ? QuantExt::CreditDefaultSwap::atDefault
370 : QuantExt::CreditDefaultSwap::atPeriodEnd;
373 for (
auto quote : quotes) {
374 QuantLib::ext::shared_ptr<SpreadCdsHelper> tmp;
376 tmp = QuantLib::ext::make_shared<SpreadCdsHelper>(
377 quote.value, quote.term, cdsConv->settlementDays(), cdsConv->calendar(), cdsConv->frequency(),
378 cdsConv->paymentConvention(), cdsConv->rule(), cdsConv->dayCounter(),
recoveryRate_, discountCurve,
379 cdsConv->settlesAccrual(), ppt, config.
startDate(), cdsConv->lastPeriodDayCounter());
381 }
catch (exception& e) {
382 if (quote.term == Period(0, Months)) {
383 WLOG(
"DefaultCurve:: Cannot add quote of term 0M to CDS curve " << curveID <<
" for asof date "
386 QL_FAIL(
"DefaultCurve:: Failed to add quote of term " << quote.term <<
" to CDS curve " << curveID
387 <<
" for asof date " << asof
388 <<
", with error: " << e.what());
392 if (tmp->latestDate() > asof) {
393 helpers.push_back(tmp);
396 helperQuoteTerms[tmp->latestDate()] = quote.term;
400 for (
auto quote : quotes) {
402 runningSpread = quote.runningSpread;
403 if (runningSpread == Null<Real>()) {
405 "A running spread was not provided in the quote "
406 <<
"string so it must be provided in the config for CDS upfront curve " << curveID);
409 auto tmp = QuantLib::ext::make_shared<UpfrontCdsHelper>(
410 quote.value, runningSpread, quote.term, cdsConv->settlementDays(), cdsConv->calendar(),
411 cdsConv->frequency(), cdsConv->paymentConvention(), cdsConv->rule(), cdsConv->dayCounter(),
412 recoveryRate_, discountCurve, cdsConv->upfrontSettlementDays(), cdsConv->settlesAccrual(), ppt,
413 config.
startDate(), cdsConv->lastPeriodDayCounter());
414 if (tmp->latestDate() > asof) {
415 helpers.push_back(tmp);
417 helperQuoteTerms[tmp->latestDate()] = quote.term;
421 QL_REQUIRE(!helpers.empty(),
"DefaultCurve: no alive quotes found.");
427 std::sort(helpers.begin(), helpers.end(), QuantLib::detail::BootstrapHelperSorter());
438 typedef PiecewiseDefaultCurve<QuantExt::SurvivalProbability, LogLinear, QuantExt::IterativeBootstrap> SpCurve;
439 SpCurve::bootstrap_type btconfig(accuracy, globalAccuracy, dontThrow, maxAttempts, maxFactor,
440 minFactor, dontThrowSteps);
441 QuantLib::ext::shared_ptr<DefaultProbabilityTermStructure> qlCurve;
448 std::vector<Real> helperTermTimes;
449 for (
auto const& h : helpers) {
454 Size helperIndex_m, helperIndex_p;
458 auto tmp1 = QuantLib::ext::make_shared<SpCurve>(
459 asof, std::vector<QuantLib::ext::shared_ptr<QuantExt::DefaultProbabilityHelper>>{helpers[helperIndex_m]},
461 Date d1 = helpers[helperIndex_m]->pillarDate();
462 Real p1 = tmp1->survivalProbability(d1);
463 auto tmp1i = QuantLib::ext::make_shared<QuantExt::InterpolatedSurvivalProbabilityCurve<LogLinear>>(
464 std::vector<Date>{asof, d1}, std::vector<Real>{1.0, p1}, config.
dayCounter(), Calendar(),
465 std::vector<Handle<Quote>>(), std::vector<Date>(), LogLinear(), config.
allowNegativeRates());
470 auto tmp2 = QuantLib::ext::make_shared<SpCurve>(
471 asof, std::vector<QuantLib::ext::shared_ptr<QuantExt::DefaultProbabilityHelper>>{helpers[helperIndex_p]},
473 Date d2 = helpers[helperIndex_p]->pillarDate();
474 Real p2 = tmp2->survivalProbability(d2);
475 auto tmp2i = QuantLib::ext::make_shared<QuantExt::InterpolatedSurvivalProbabilityCurve<LogLinear>>(
476 std::vector<Date>{asof, d2}, std::vector<Real>{1.0, p2}, config.
dayCounter(), Calendar(),
477 std::vector<Handle<Quote>>(), std::vector<Date>(), LogLinear(), config.
allowNegativeRates());
478 tmp1i->enableExtrapolation();
479 tmp2i->enableExtrapolation();
480 qlCurve = QuantLib::ext::make_shared<QuantExt::TermInterpolatedDefaultCurve>(
481 Handle<DefaultProbabilityTermStructure>(tmp1i), Handle<DefaultProbabilityTermStructure>(tmp2i), alpha);
488 QuantLib::ext::shared_ptr<DefaultProbabilityTermStructure> tmp = QuantLib::ext::make_shared<SpCurve>(
489 asof, helpers, config.
dayCounter(), LogLinear(),
491 minFactor, dontThrowSteps));
496 vector<Real> survivalProbs;
497 dates.push_back(asof);
498 survivalProbs.push_back(1.0);
500 for (Size i = 0; i < helpers.size(); ++i) {
501 if (helpers[i]->latestDate() > asof) {
502 Date pillarDate = helpers[i]->pillarDate();
503 Probability sp = tmp->survivalProbability(pillarDate);
508 if (!survivalProbs.empty() && close(survivalProbs.back(), sp)) {
509 DLOG(
"Survival probability for curve " <<
spec.
name() <<
" at date " << io::iso_date(pillarDate)
510 <<
" is the same as that at previous date "
511 << io::iso_date(dates.back()) <<
" so skipping it.");
515 dates.push_back(pillarDate);
516 survivalProbs.push_back(sp);
517 TLOG(io::iso_date(pillarDate) <<
"," << fixed << setprecision(9) << sp);
520 if (dates.size() == 1) {
522 dates.push_back(dates.back() + 1);
523 survivalProbs.push_back(survivalProbs.back());
525 qlCurve = QuantLib::ext::make_shared<QuantExt::InterpolatedSurvivalProbabilityCurve<LogLinear>>(
526 dates, survivalProbs, config.
dayCounter(), Calendar(), std::vector<Handle<Quote>>(), std::vector<Date>(),
531 qlCurve->enableExtrapolation();
532 DLOG(
"DefaultCurve: Enabled Extrapolation");
535 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(Handle<DefaultProbabilityTermStructure>(qlCurve), discountCurve,
536 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(
recoveryRate_)),
539 LOG(
"Finished building default curve of type SpreadCDS for curve " << curveID);
545 LOG(
"Start building default curve of type HazardRate for curve " << curveID);
548 "DefaultCurve::buildHazardRateCurve expected a default curve configuration with type HazardRate");
551 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
553 QuantLib::ext::shared_ptr<CdsConvention> cdsConv =
554 QuantLib::ext::dynamic_pointer_cast<CdsConvention>(conventions->get(config.
conventionID()));
555 QL_REQUIRE(cdsConv,
"HazardRate curves require CDS convention");
558 set<QuoteData> quotes = getConfiguredQuotes(curveID, config, asof, loader);
561 Calendar cal = cdsConv->calendar();
563 vector<Real> quoteValues;
566 if (quotes.begin()->term != 0 * Days) {
567 LOG(
"DefaultCurve: add asof (" << asof <<
"), hazard rate " << quotes.begin()->value <<
", as not given");
568 dates.push_back(asof);
569 quoteValues.push_back(quotes.begin()->value);
572 for (
auto quote : quotes) {
573 dates.push_back(cal.advance(asof, quote.term, Following,
false));
574 quoteValues.push_back(quote.value);
577 LOG(
"DefaultCurve: set up interpolated hazard rate curve");
578 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(
583 curve_->curve()->enableExtrapolation();
584 DLOG(
"DefaultCurve: Enabled Extrapolation");
588 LOG(
"DefaultCurve: setting recovery rate to 0.0 for hazard rate curve, because none is given.");
593 curve_->curve()->survivalProbability(QL_EPSILON);
595 LOG(
"Finished building default curve of type HazardRate for curve " << curveID);
600 map<
string, QuantLib::ext::shared_ptr<YieldCurve>>& yieldCurves) {
602 LOG(
"Start building default curve of type Benchmark for curve " << curveID);
605 "DefaultCurve::buildBenchmarkCurve expected a default curve configuration with type Benchmark");
612 QL_REQUIRE(it != yieldCurves.end(),
"The benchmark curve, " << config.
benchmarkCurveID()
613 <<
", required in the building of the curve, "
614 <<
spec.
name() <<
", was not found.");
615 QuantLib::ext::shared_ptr<YieldCurve> benchmarkCurve = it->second;
619 QL_REQUIRE(it != yieldCurves.end(),
"The source curve, " << config.
sourceCurveID()
620 <<
", required in the building of the curve, "
621 <<
spec.
name() <<
", was not found.");
622 QuantLib::ext::shared_ptr<YieldCurve> sourceCurve = it->second;
627 Size spotLag = config.
spotLag();
631 vector<Real> impliedSurvProb;
632 Date spot = cal.advance(asof, spotLag * Days);
633 for (Size i = 0; i < pillars.size(); ++i) {
634 dates.push_back(cal.advance(spot, pillars[i]));
635 Real tmp = dates[i] == asof
637 : sourceCurve->handle()->discount(dates[i]) / benchmarkCurve->handle()->discount(dates[i]);
640 impliedSurvProb.push_back(std::pow(tmp, 1.0 / (1.0 -
recoveryRate_)));
642 QL_REQUIRE(dates.size() > 0,
"DefaultCurve (Benchmark): no dates given");
645 if (dates[0] != asof) {
646 dates.insert(dates.begin(), asof);
647 impliedSurvProb.insert(impliedSurvProb.begin(), 1.0);
650 LOG(
"DefaultCurve: set up interpolated surv prob curve as yield over benchmark");
651 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(Handle<DefaultProbabilityTermStructure>(
653 dates, impliedSurvProb, config.
dayCounter(), Calendar(), std::vector<Handle<Quote>>(), std::vector<Date>(),
657 curve_->curve()->enableExtrapolation();
658 DLOG(
"DefaultCurve: Enabled Extrapolation");
662 curve_->curve()->survivalProbability(QL_EPSILON);
664 LOG(
"Finished building default curve of type Benchmark for curve " << curveID);
669 map<
string, QuantLib::ext::shared_ptr<DefaultCurve>>& defaultCurves) {
670 LOG(
"Start building default curve of type MultiSection for curve " << curveID);
672 std::vector<Handle<DefaultProbabilityTermStructure>> curves;
673 std::vector<Handle<Quote>> recoveryRates;
674 std::vector<Date> switchDates;
677 auto it = defaultCurves.find(s);
678 QL_REQUIRE(it != defaultCurves.end(),
679 "The multi section source curve " << s <<
" required for " <<
spec.
name() <<
" was not found.");
680 curves.push_back(Handle<DefaultProbabilityTermStructure>(it->second->creditCurve()->curve()));
681 recoveryRates.push_back(Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(it->second->recoveryRate())));
689 LOG(
"DefaultCurve: set up multi section curve with " << curves.size() <<
" sections");
690 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(
691 Handle<DefaultProbabilityTermStructure>(QuantLib::ext::make_shared<QuantExt::MultiSectionDefaultCurve>(
694 LOG(
"Finished building default curve of type MultiSection for curve " << curveID);
699 map<
string, QuantLib::ext::shared_ptr<DefaultCurve>>& defaultCurves) {
700 LOG(
"Start building default curve of type TransitionMatrix for curve " << curveID);
701 Size dim = config.
states().size();
703 "DefaultCurve::buildTransitionMatrixCurve(): transition matrix dimension >= 2 required, found " << dim);
704 Matrix transitionMatrix(dim, dim, Null<Real>());
705 map<string, Size> stateIndex;
706 for (Size i = 0; i < config.
states().
size(); ++i)
707 stateIndex[config.
states()[i]] = i;
708 QL_REQUIRE(!config.
cdsQuotes().empty(),
"DefaultCurve::buildTransitionMatrixCurve(): not quotes given.");
709 std::vector<std::string> tmp;
710 std::transform(config.
cdsQuotes().begin(), config.
cdsQuotes().end(), std::back_inserter(tmp),
711 [](
const std::pair<std::string, bool>& p) { return p.first; });
713 std::set<QuantLib::ext::shared_ptr<MarketDatum>> mdData;
715 mdData = loader.
get(*wildcard, asof);
717 for (
auto const& q : config.
cdsQuotes()) {
718 if (
auto m = loader.
get(q, asof))
722 for (
const auto& md : mdData) {
724 "DefaultCurve::buildTransitionMatrixCurve(): quote instrument type must be RATING.");
725 QuantLib::ext::shared_ptr<TransitionProbabilityQuote> q = QuantLib::ext::dynamic_pointer_cast<TransitionProbabilityQuote>(md);
726 Size i = stateIndex[q->fromRating()];
727 Size j = stateIndex[q->toRating()];
728 transitionMatrix[i][j] = q->quote()->value();
730 for (Size i = 0; i < dim; ++i) {
731 for (Size j = 0; j < dim; ++j) {
732 QL_REQUIRE(transitionMatrix[i][j] != Null<Real>(),
733 "DefaultCurve::buildTransitionMatrixCurve():matrix element "
734 << config.
states()[i] <<
" -> " << config.
states()[j] <<
" missing in market data");
737 Size initialStateIndex = stateIndex[config.
initialState()];
738 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(
739 Handle<DefaultProbabilityTermStructure>(QuantLib::ext::make_shared<QuantExt::GeneratorDefaultProbabilityTermStructure>(
740 QuantExt::GeneratorDefaultProbabilityTermStructure::MatrixType::Transition, transitionMatrix,
741 initialStateIndex, asof)));
744 LOG(
"Finished building default curve of type TransitionMatrix for curve " << curveID);
749 LOG(
"Start building null default curve for " << curveID);
750 curve_ = QuantLib::ext::make_shared<QuantExt::CreditCurve>(Handle<DefaultProbabilityTermStructure>(
751 QuantLib::ext::make_shared<QuantLib::FlatHazardRate>(asof, 0.0, config.
dayCounter())));
753 LOG(
"Finished building default curve of type Null for curve " << curveID);
QuantLib::Real maxFactor() const
QuantLib::Size dontThrowSteps() const
QuantLib::Real globalAccuracy() const
QuantLib::Real accuracy() const
QuantLib::Real minFactor() const
QuantLib::Size maxAttempts() const
Container class for all Curve Configurations.
const std::string & curveConfigID() const
string name() const
returns the unique curve name
const Real runningSpread() const
const Type & type() const
Type
Supported default curve types.
const QuantLib::Period & indexTerm() const
const string & discountCurveID() const
const QuantLib::Date & startDate() const
const vector< string > & multiSectionSwitchDates() const
const boost::optional< bool > & implyDefaultFromMarket() const
const DayCounter & dayCounter() const
const Calendar & calendar() const
const Size & spotLag() const
const string & benchmarkCurveID() const
const bool allowNegativeRates() const
bool extrapolation() const
const std::vector< string > & pillars() const
const vector< string > & states() const
const string & conventionID() const
const std::vector< std::pair< std::string, bool > > & cdsQuotes() const
const vector< string > & multiSectionSourceCurveIds() const
const BootstrapConfig & bootstrapConfig() const
const string & initialState() const
const string & sourceCurveID() const
const string & recoveryRateQuote() const
QuantLib::ext::shared_ptr< QuantExt::CreditCurve > curve_
DefaultCurve()
Default constructor.
void buildHazardRateCurve(const std::string &curveID, const DefaultCurveConfig::Config &config, const QuantLib::Date &asof, const DefaultCurveSpec &spec, const Loader &loader)
Build a default curve from hazard rate quotes.
const DefaultCurveSpec & spec() const
void buildMultiSectionCurve(const std::string &curveID, const DefaultCurveConfig::Config &config, const Date &asof, const DefaultCurveSpec &spec, const Loader &loader, map< string, QuantLib::ext::shared_ptr< DefaultCurve > > &defaultCurves)
Build a multi section curve.
void buildCdsCurve(const std::string &curveID, const DefaultCurveConfig::Config &config, const QuantLib::Date &asof, const DefaultCurveSpec &spec, const Loader &loader, std::map< std::string, QuantLib::ext::shared_ptr< YieldCurve > > &yieldCurves)
Build a default curve from CDS spread quotes.
void buildBenchmarkCurve(const std::string &curveID, const DefaultCurveConfig::Config &config, const QuantLib::Date &asof, const DefaultCurveSpec &spec, const Loader &loader, std::map< std::string, QuantLib::ext::shared_ptr< YieldCurve > > &yieldCurves)
Build a default curve implied from a spread over a benchmark curve.
void buildTransitionMatrixCurve(const std::string &curveID, const DefaultCurveConfig::Config &config, const Date &asof, const DefaultCurveSpec &spec, const Loader &loader, map< string, QuantLib::ext::shared_ptr< DefaultCurve > > &defaultCurves)
void buildNullCurve(const std::string &curveID, const DefaultCurveConfig::Config &config, const Date &asof, const DefaultCurveSpec &spec)
Build a null curve (null rate, null recovery)
Default curve description.
Market data loader base class.
virtual QuantLib::ext::shared_ptr< MarketDatum > get(const std::string &name, const QuantLib::Date &d) const
get quote by its unique name, throws if not existent, override in derived classes for performance
virtual bool has(const std::string &name, const QuantLib::Date &d) const
Default implementation, returns false if get throws or returns a null pointer.
InstrumentType
Supported market instrument types.
QuoteType
Supported market quote types.
const std::string & pattern() const
bool matches(const std::string &s) const
SafeStack< ValueType > value
Wrapper class for building Default curves.
bool tryParseReal(const string &s, QuantLib::Real &result)
Attempt to convert text to Real.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Classes and functions for log message handling.
#define LOG(text)
Logging Macro (Level = Notice)
#define DLOG(text)
Logging Macro (Level = Debug)
#define WLOG(text)
Logging Macro (Level = Warning)
#define TLOG(text)
Logging Macro (Level = Data)
bool operator<(const Dividend &d1, const Dividend &d2)
std::tuple< Size, Size, Real > interpolationIndices(const T &x, const Real v)
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
Real periodToTime(const Period &p)
Size size(const ValueType &v)
boost::optional< Wildcard > getUniqueWildcard(const C &c)
checks if at most one element in C has a wild card and returns it in this case
Serializable Credit Default Swap.
QuantLib::DayCounter lastPeriodDayCounter
QuantLib::Period indexTerm
QuantLib::DateGeneration::Rule rule
QuantLib::DayCounter dayCounter
QuantLib::Natural cashSettlementDays
QuantLib::BusinessDayConvention termConvention
QuantLib::Calendar calendar
QuantLib::BusinessDayConvention payConvention
QuantLib::BusinessDayConvention convention
QuantLib::Real runningSpread
vector< string > curveConfigs
utilities for wildcard handling
Wrapper class for QuantLib term structures.