35#include <ql/processes/blackscholesprocess.hpp>
37#include <boost/make_shared.hpp>
49 const string&, const string&, const string&> {
54 virtual std::string
keyImpl(
const string&
id,
const Currency& ccy,
const string& creditCurveId,
55 const bool hasCreditRisk,
const string& securityId,
const string& referenceCurveId,
56 const string& volatilityCurveId)
override {
58 return ccy.code() +
"_" + creditCurveId +
"_" + (hasCreditRisk ?
"1_" :
"0_") + securityId +
"_" +
59 referenceCurveId +
"_" + volatilityCurveId +
"_" +
"BondOption";
62 virtual QuantLib::ext::shared_ptr<QuantLib::PricingEngine>
63 engineImpl(
const string&
id,
const Currency& ccy,
const string& creditCurveId,
const bool hasCreditRisk,
64 const string& securityId,
const string& referenceCurveId,
const string& volatilityCurveId)
override {
66 Handle<YieldTermStructure> discountCurve =
68 QL_REQUIRE(!volatilityCurveId.empty(),
"BondOptionEngineBuilder: volatility curve ID for trade id '"
69 <<
id <<
"', security id '" << securityId <<
"' not given");
70 Handle<QuantLib::SwaptionVolatilityStructure> yieldVola =
73 Handle<DefaultProbabilityTermStructure> dpts;
75 if (!creditCurveId.empty())
79 Handle<Quote> recovery;
85 ALOG(
"security specific recovery rate not found for security ID "
86 << securityId <<
", falling back on the recovery rate for credit curve Id " << creditCurveId);
87 if (!creditCurveId.empty())
98 dpts = Handle<DefaultProbabilityTermStructure>();
101 return QuantLib::ext::make_shared<QuantExt::BlackBondOptionEngine>(
Abstract template engine builder class.
Engine builder for bond option.
virtual std::string keyImpl(const string &id, const Currency &ccy, const string &creditCurveId, const bool hasCreditRisk, const string &securityId, const string &referenceCurveId, const string &volatilityCurveId) override
virtual QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engineImpl(const string &id, const Currency &ccy, const string &creditCurveId, const bool hasCreditRisk, const string &securityId, const string &referenceCurveId, const string &volatilityCurveId) override
BondOptionEngineBuilder()
Abstract template EngineBuilder class that can cache engines and coupon pricers.
QuantLib::ext::shared_ptr< Market > market_
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
#define ALOG(text)
Logging Macro (Level = Alert)
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.