27#include <qle/pricingengines/pairwisevarianceswapengine.hpp>
31#include <boost/make_shared.hpp>
38#include <ql/processes/blackscholesprocess.hpp>
39#include <ql/version.hpp>
58 {
"EquityPairwiseVarianceSwap",
"FxPairwiseVarianceSwap"}) {}
61 virtual string keyImpl(
const string& underlyingName1,
const string& underlyingName2,
const Currency& ccy,
62 const Date& accrEndDate,
const AssetClass& assetClassUnderlyings)
override {
63 return underlyingName1 +
"/" + underlyingName2 +
"/" + ccy.code();
66 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const string& underlyingName1,
const string& underlyingName2,
67 const Currency& ccy,
const Date& accrEndDate,
68 const AssetClass& assetClassUnderlyings)
override {
69 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp1, gbsp2;
70 QuantLib::ext::shared_ptr<Index> index1, index2;
72 gbsp1 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
77 index1 =
market_->equityCurve(underlyingName1).currentLink();
78 gbsp2 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
83 index2 =
market_->equityCurve(underlyingName2).currentLink();
85 const auto fxIndex1 =
market_->fxIndex(
"FX-" + underlyingName1);
86 const auto fxIndex2 =
market_->fxIndex(
"FX-" + underlyingName2);
87 const string& ccyPairCode1 = fxIndex1->sourceCurrency().code() + fxIndex1->targetCurrency().code();
88 const string& ccyPairCode2 = fxIndex2->sourceCurrency().code() + fxIndex2->targetCurrency().code();
89 gbsp1 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
91 fxIndex1->targetCurve(), fxIndex1->sourceCurve(),
93 gbsp2 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
95 fxIndex2->targetCurve(), fxIndex2->sourceCurve(),
97 index1 = fxIndex1.currentLink();
98 index2 = fxIndex2.currentLink();
101 QL_FAIL(
"Asset class of " + underlyingName1 +
" and " + underlyingName2 +
" not recognized.");
104 QuantLib::Handle<QuantExt::CorrelationTermStructure> corrCurve(
105 QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0, NullCalendar(), 0.0, Actual365Fixed()));
106 Handle<Quote> correlation(
107 QuantLib::ext::make_shared<QuantExt::CorrelationValue>(corrCurve, corrCurve->timeFromReference(accrEndDate)));
113 WLOG(
"no correlation curve for " << index1->name() <<
", " << index2->name()
114 <<
" found, fall back to zero correlation");
117 return QuantLib::ext::make_shared<QuantExt::PairwiseVarianceSwapEngine>(
118 index1, index2, gbsp1, gbsp2,
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
QuantLib::ext::shared_ptr< Market > market_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Engine Builder for Pairwise Variance Swaps.
virtual string keyImpl(const string &underlyingName1, const string &underlyingName2, const Currency &ccy, const Date &accrEndDate, const AssetClass &assetClassUnderlyings) override
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &underlyingName1, const string &underlyingName2, const Currency &ccy, const Date &accrEndDate, const AssetClass &assetClassUnderlyings) override
PairwiseVarSwapEngineBuilder()
Map text representations to QuantLib/QuantExt types.
Classes and functions for log message handling.
#define WLOG(text)
Logging Macro (Level = Warning)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities