2323
2424#pragma once
2525
26- #include < boost/make_shared.hpp>
2726#include < ored/portfolio/builders/cachingenginebuilder.hpp>
2827#include < ored/portfolio/enginefactory.hpp>
28+ #include < ored/utilities/marketdata.hpp>
29+
2930#include < qle/pricingengines/discountingfxforwardengine.hpp>
3031
32+ #include < boost/make_shared.hpp>
33+
3134namespace ore {
3235namespace data {
3336
@@ -36,15 +39,17 @@ namespace data {
3639 \ingroup builders
3740*/
3841class FxForwardEngineBuilderBase
39- : public CachingPricingEngineBuilder<string, const Currency&, const Currency&> {
42+ : public CachingPricingEngineBuilder<string, const Currency&, const Currency&, const string& > {
4043public:
4144 FxForwardEngineBuilderBase (const std::string& model, const std::string& engine)
4245 : CachingEngineBuilder(model, engine, {" FxForward" }) {}
4346
4447protected:
45- string keyImpl (const Currency& forCcy, const Currency& domCcy) override {
46- return forCcy.code () + domCcy.code ();
48+ string keyImpl (const Currency& forCcy, const Currency& domCcy, const std::string& discountCurve ) override {
49+ return forCcy.code () + domCcy.code () + " _ " + discountCurve ;
4750 }
51+
52+ std::string discountCurve_;
4853};
4954
5055// ! Engine Builder for FX Forwards
@@ -56,12 +61,16 @@ class FxForwardEngineBuilder : public FxForwardEngineBuilderBase {
5661 FxForwardEngineBuilder () : FxForwardEngineBuilderBase(" DiscountedCashflows" , " DiscountingFxForwardEngine" ) {}
5762
5863protected:
59- QuantLib::ext::shared_ptr<PricingEngine> engineImpl (const Currency& forCcy, const Currency& domCcy) override {
60- string pair = keyImpl (forCcy, domCcy);
64+ QuantLib::ext::shared_ptr<PricingEngine> engineImpl (const Currency& forCcy, const Currency& domCcy,
65+ const std::string& discountCurve) override {
66+ std::cout << " getting curve '" << discountCurve << " '" << std::endl;
67+ string pair = forCcy.code () + domCcy.code ();
6168 return QuantLib::ext::make_shared<QuantExt::DiscountingFxForwardEngine>(
6269 domCcy, market_->discountCurve (domCcy.code (), configuration (MarketContext::pricing)), forCcy,
6370 market_->discountCurve (forCcy.code (), configuration (MarketContext::pricing)),
64- market_->fxRate (pair, configuration (MarketContext::pricing)));
71+ market_->fxRate (pair, configuration (MarketContext::pricing)), QuantLib::Date (), QuantLib::Date (),
72+ discountCurve.empty () ? Handle<YieldTermStructure>{}
73+ : indexOrYieldCurve (market_, discountCurve, configuration (MarketContext::pricing)));
6574 }
6675};
6776
@@ -75,7 +84,8 @@ class CamAmcFxForwardEngineBuilder : public FxForwardEngineBuilderBase {
7584 stickyCloseOutDates_ (stickyCloseOutDates) {}
7685
7786protected:
78- QuantLib::ext::shared_ptr<PricingEngine> engineImpl (const Currency& forCcy, const Currency& domCcy) override ;
87+ QuantLib::ext::shared_ptr<PricingEngine> engineImpl (const Currency& forCcy, const Currency& domCcy,
88+ const std::string& discountCurve) override ;
7989
8090private:
8191 const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel> cam_;
@@ -93,7 +103,8 @@ class AmcCgFxForwardEngineBuilder : public FxForwardEngineBuilderBase {
93103 }
94104
95105protected:
96- QuantLib::ext::shared_ptr<PricingEngine> engineImpl (const Currency& forCcy, const Currency& domCcy) override ;
106+ QuantLib::ext::shared_ptr<PricingEngine> engineImpl (const Currency& forCcy, const Currency& domCcy,
107+ const std::string& discountCurve) override ;
97108
98109private:
99110 const QuantLib::ext::shared_ptr<ore::data::ModelCG> modelCg_;
0 commit comments