26#include <boost/make_shared.hpp>
29#include <ql/pricingengines/quanto/quantoengine.hpp>
44 const AssetClass& assetClass,
const Date& expiryDate)
47 QuantLib::ext::shared_ptr<PricingEngine>
engine(
const string& assetName,
const Currency& underlyingCcy,
48 const Currency& payCcy,
const Date& expiryDate) {
55 virtual string keyImpl(
const string& assetName,
const Currency& underlyingCcy,
const Currency& payCcy,
56 const AssetClass& assetClassUnderlying,
const Date& expiryDate)
override {
57 return assetName +
"/" + underlyingCcy.code() +
"/" + payCcy.code() +
"/" +
to_string(expiryDate);
74 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const string& assetName,
const Currency& underlyingCcy,
75 const Currency& payCcy,
const AssetClass& assetClassUnderlying,
76 const Date& expiryDate)
override {
77 QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> gbsp =
80 Handle<YieldTermStructure> discountCurve =
83 Handle<BlackVolTermStructure> fxVolatility =
87 std::string fxIndex =
"FX-" + fxSource +
"-" + underlyingCcy.code() +
"-" + payCcy.code();
88 std::string underlyingIndex;
89 switch (assetClassUnderlying) {
91 underlyingIndex =
"EQ-" + assetName;
94 underlyingIndex =
"COMM-" + assetName;
97 QL_FAIL(
"Asset class " << assetClassUnderlying <<
" not supported for quanto vanilla option.");
100 QuantLib::Handle<QuantExt::CorrelationTermStructure> corrCurve(
101 QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0, NullCalendar(), 0.0, Actual365Fixed()));
105 WLOG(
"no correlation curve for " << fxIndex <<
", " << underlyingIndex
106 <<
" found, fall back to zero correlation");
109 return QuantLib::ext::make_shared<QuantLib::QuantoEngine<VanillaOption, QuantLib::AnalyticEuropeanEngine>>(
110 gbsp, discountCurve, fxVolatility,
112 QuantLib::ext::make_shared<QuantExt::CorrelationValue>(corrCurve, corrCurve->timeFromReference(expiryDate))));
Abstract engine builders for European and American Options.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > getBlackScholesProcess(const string &assetName, const Currency &ccy, const AssetClass &assetClassUnderlying, const std::vector< Time > &timePoints={}, const bool useFxSpot=true)
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
const set< string > & tradeTypes() const
Return the possible trade types.
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)
map< string, string > modelParameters_
Abstract Engine Builder for Quanto European Vanilla Options.
QuantoEuropeanOptionEngineBuilder(const string &model, const set< string > &tradeTypes, const AssetClass &assetClass)
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &assetName, const Currency &underlyingCcy, const Currency &payCcy, const AssetClass &assetClassUnderlying, const Date &expiryDate) override
Abstract Engine Builder for Quanto Vanilla Options.
QuantoVanillaOptionEngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes, const AssetClass &assetClass, const Date &expiryDate)
virtual string keyImpl(const string &assetName, const Currency &underlyingCcy, const Currency &payCcy, const AssetClass &assetClassUnderlying, const Date &expiryDate) override
QuantLib::ext::shared_ptr< PricingEngine > engine(const string &assetName, const Currency &underlyingCcy, const Currency &payCcy, const Date &expiryDate)
#define WLOG(text)
Logging Macro (Level = Warning)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.