37#include <ql/termstructures/yield/zerospreadedtermstructure.hpp>
39#include <boost/make_shared.hpp>
46 const string&, const string&, const string&> {
51 virtual string keyImpl(
const string&
id,
const Currency& ccy,
const string& creditCurveId,
const bool hasCreditRisk,
52 const string& securityId,
const string& referenceCurveId,
53 const string& incomeCurveId)
override {
56 std::string returnString = ccy.code() +
"_" + creditCurveId +
"_" + (hasCreditRisk ?
"1_" :
"0_") + securityId +
57 "_" + referenceCurveId +
"_" + incomeCurveId;
69 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const string&
id,
const Currency& ccy,
70 const string& creditCurveId,
const bool hasCreditRisk,
71 const string& securityId,
const string& referenceCurveId,
72 const string& incomeCurveId)
override {
78 Handle<YieldTermStructure> discountTS =
81 Handle<YieldTermStructure> incomeTS =
market_->yieldCurve(
83 Handle<DefaultProbabilityTermStructure> dpts;
85 if (!creditCurveId.empty())
89 Handle<Quote> recovery;
94 WLOG(
"security specific recovery rate not found for security ID "
95 << securityId <<
", falling back on the recovery rate for credit curve Id " << creditCurveId);
96 if (!creditCurveId.empty())
100 Handle<Quote> bondSpread;
107 if (!hasCreditRisk) {
108 dpts = Handle<DefaultProbabilityTermStructure>();
111 return QuantLib::ext::make_shared<QuantExt::DiscountingForwardBondEngine>(discountTS, incomeTS, yts, bondSpread, dpts,
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &id, const Currency &ccy, const string &creditCurveId, const bool hasCreditRisk, const string &securityId, const string &referenceCurveId, const string &incomeCurveId) override
DiscountingForwardBondEngineBuilder()
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
map< string, string > engineParameters_
const string & model() const
Return the model name.
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
fwdBondEngineBuilder(const std::string &model, const std::string &engine)
virtual string keyImpl(const string &id, const Currency &ccy, const string &creditCurveId, const bool hasCreditRisk, const string &securityId, const string &referenceCurveId, const string &incomeCurveId) override
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Classes and functions for log message handling.
#define WLOG(text)
Logging Macro (Level = Warning)
market data related utilties
QuantLib::Handle< QuantExt::CreditCurve > securitySpecificCreditCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &securityId, const std::string &creditCurveId, const std::string &configuration)
Serializable Credit Default Swap.
Structured Trade Error class.
string conversion utilities