59 {
60
62
63 auto qlBond = QuantLib::ext::dynamic_pointer_cast<QuantLib::Bond>(
bond_.
instrument()->qlInstrument());
64 QL_REQUIRE(qlBond, "buildBondIndex(): could not cast to QuantLib::Bond, this is unexpected");
65
66
69
70 Handle<YieldTermStructure> discountCurve = engineFactory->market()->yieldCurve(
72
73 Handle<DefaultProbabilityTermStructure> defaultCurve;
74 if (!bondData.creditCurveId().empty())
77 ->curve();
78
79 Handle<YieldTermStructure> incomeCurve;
80 if (!bondData.incomeCurveId().empty())
81 incomeCurve = engineFactory->market()->yieldCurve(bondData.incomeCurveId(),
83
84 Handle<Quote> recovery;
85 try {
86 recovery =
88 } catch (...) {
89 WLOG(
"security specific recovery rate not found for security ID "
90 << securityId << ", falling back on the recovery rate for credit curve Id " << bondData.creditCurveId());
91 if (!bondData.creditCurveId().empty())
92 recovery = engineFactory->market()->recoveryRate(bondData.creditCurveId(),
94 }
95
96 Handle<Quote> spread(QuantLib::ext::make_shared<SimpleQuote>(0.0));
97 try {
98 spread =
100 } catch (...) {
101 }
102
103 if (!bondData.hasCreditRisk())
104 defaultCurve = Handle<DefaultProbabilityTermStructure>();
105
106
107 bondIndex_ = QuantLib::ext::make_shared<QuantExt::BondIndex>(securityId,
dirty_, relative, fixingCalendar, qlBond,
108 discountCurve, defaultCurve, recovery, spread, incomeCurve, conditionalOnSurvival,
parseDate(bondData.issueDate()), bondData.priceQuoteMethod(),
109 bondData.priceQuoteBaseValue(), bondData.isInflationLinked(), bidAskAdjustment, bondIssueDateFallback);
110}
const string & securityId() const
const RequiredFixings & requiredFixings() const
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument() const
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
#define WLOG(text)
Logging Macro (Level = Warning)
QuantLib::Handle< QuantExt::CreditCurve > securitySpecificCreditCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &securityId, const std::string &creditCurveId, const std::string &configuration)