36#include <ql/pricingengines/swap/discountingswapengine.hpp>
37#include <ql/termstructures/yield/zerospreadedtermstructure.hpp>
39#include <boost/make_shared.hpp>
55 virtual string keyImpl(
const Currency& ccy,
const std::string& discountCurve,
56 const std::string& securitySpread)
override {
57 return ccy.code() + discountCurve + securitySpread;
70 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const Currency& ccy,
const std::string& discountCurve,
71 const std::string& securitySpread)
override {
72 Handle<YieldTermStructure> yts =
75 if (!securitySpread.empty())
76 yts = Handle<YieldTermStructure>(QuantLib::ext::make_shared<ZeroSpreadedTermStructure>(
78 return QuantLib::ext::make_shared<QuantLib::DiscountingSwapEngine>(yts);
91 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const Currency& ccy,
const std::string& discountCurve,
92 const std::string& securitySpread)
override {
94 Handle<YieldTermStructure> yts =
97 if (!securitySpread.empty())
98 yts = Handle<YieldTermStructure>(QuantLib::ext::make_shared<ZeroSpreadedTermStructure>(
100 return QuantLib::ext::make_shared<QuantExt::DiscountingSwapEngineMultiCurve>(yts);
116 virtual string keyImpl(
const std::vector<Currency>& ccys,
const Currency& base)
override {
117 std::ostringstream ccyskey;
118 ccyskey << base <<
"/";
119 for (Size i = 0; i < ccys.size(); ++i)
120 ccyskey << ccys[i] << ((i < ccys.size() - 1) ?
"-" :
"");
121 return ccyskey.str();
132 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const std::vector<Currency>& ccys,
133 const Currency& base)
override {
135 std::vector<Handle<YieldTermStructure>> discountCurves;
136 std::vector<Handle<Quote>> fxQuotes;
138 std::string baseCcyCode = base.code();
139 for (Size i = 0; i < ccys.size(); ++i) {
140 string ccyCode = ccys[i].code();
142 string pair = ccyCode + baseCcyCode;
143 fxQuotes.push_back(
market_->fxRate(pair, config));
146 return QuantLib::ext::make_shared<QuantExt::DiscountingCurrencySwapEngine>(discountCurves, fxQuotes, ccys, base);
156 const std::vector<Date>& simulationDates)
161 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const Currency& ccy,
const std::string& discountCurve,
162 const std::string& securitySpread)
override;
165 QuantLib::ext::shared_ptr<PricingEngine>
buildMcEngine(
const QuantLib::ext::shared_ptr<QuantExt::LGM>& lgm,
166 const Handle<YieldTermStructure>& discountCurve,
167 const std::vector<Date>& simulationDates,
168 const std::vector<Size>& externalModelIndices);
169 const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel>
cam_;
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
Implementation of SwapEngineBuilderBase using MC pricer for external cam / AMC.
const std::vector< Date > simulationDates_
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > cam_
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &ccy, const std::string &discountCurve, const std::string &securitySpread) override
QuantLib::ext::shared_ptr< PricingEngine > buildMcEngine(const QuantLib::ext::shared_ptr< QuantExt::LGM > &lgm, const Handle< YieldTermStructure > &discountCurve, const std::vector< Date > &simulationDates, const std::vector< Size > &externalModelIndices)
CamAmcSwapEngineBuilder(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &cam, const std::vector< Date > &simulationDates)
Engine Builder base class for Cross Currency Swaps.
CrossCurrencySwapEngineBuilderBase(const std::string &model, const std::string &engine)
virtual string keyImpl(const std::vector< Currency > &ccys, const Currency &base) override
Discounted Cashflows Engine Builder for Cross Currency Swaps.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const std::vector< Currency > &ccys, const Currency &base) override
CrossCurrencySwapEngineBuilder()
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
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)
Engine Builder base class for Single Currency Swaps.
virtual string keyImpl(const Currency &ccy, const std::string &discountCurve, const std::string &securitySpread) override
SwapEngineBuilderBase(const std::string &model, const std::string &engine)
Engine Builder for Single Currency Swaps.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &ccy, const std::string &discountCurve, const std::string &securitySpread) override
Engine Builder for Single Currency Swaps.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &ccy, const std::string &discountCurve, const std::string &securitySpread) override
SwapEngineBuilderOptimised()
Classes and functions for log message handling.
market data related utilties
Handle< YieldTermStructure > xccyYieldCurve(const QuantLib::ext::shared_ptr< Market > &market, const string &ccyCode, const string &configuration)
Handle< YieldTermStructure > indexOrYieldCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &name, const std::string &configuration)
Serializable Credit Default Swap.