88 {
89
90 BOOST_TEST_MESSAGE("Testing FxVolatility Curve Wildcards");
91
92 std::vector<std::pair<std::string, std::string>>
curveConfigs = {
93 { "curveconfig_full.xml", "curveconfig_wc.xml" },
94 { "curveconfig_full_M.xml", "curveconfig_wc_M.xml" }
95 };
96
98 Date asof(31, Dec, 2018);
99 TodaysMarketArguments tma_full(asof, c.first);
100 TodaysMarketArguments tma_wc(asof, c.second);
101
102
103 QuantLib::ext::shared_ptr<TodaysMarket> market_full = QuantLib::ext::make_shared<TodaysMarket>(tma_full.asof, tma_full.todaysMarketParameters,
104 tma_full.loader, tma_full.curveConfigs, false, true, false);
105 QuantLib::ext::shared_ptr<TodaysMarket> market_wc = QuantLib::ext::make_shared<TodaysMarket>(tma_wc.asof, tma_wc.todaysMarketParameters,
106 tma_wc.loader, tma_wc.curveConfigs, false, true, false);
107
108
109
110
111 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
112 engineData->model("FxOption") = "GarmanKohlhagen";
113 engineData->engine("FxOption") = "AnalyticEuropeanEngine";
114 QuantLib::ext::shared_ptr<EngineFactory> engineFactory_full = QuantLib::ext::make_shared<EngineFactory>(engineData, market_full);
115 QuantLib::ext::shared_ptr<EngineFactory> engineFactory_wc = QuantLib::ext::make_shared<EngineFactory>(engineData, market_wc);
116
117
118 string portfolioFile = "portfolio.xml";
119 QuantLib::ext::shared_ptr<Portfolio> portfolio_full = QuantLib::ext::make_shared<Portfolio>();
120 portfolio_full->fromFile(TEST_INPUT_FILE(portfolioFile));
121 portfolio_full->build(engineFactory_full);
122
123 QuantLib::ext::shared_ptr<Portfolio> portfolio_wc = QuantLib::ext::make_shared<Portfolio>();
124 portfolio_wc->fromFile(TEST_INPUT_FILE(portfolioFile));
125 portfolio_wc->build(engineFactory_wc);
126
127 BOOST_CHECK_EQUAL(portfolio_full->size(), portfolio_wc->size());
128
129 auto portfolioFullIt = portfolio_full->trades().begin();
130 auto portfolioWCIt = portfolio_wc->trades().begin();
131
132 for (Size i = 0; i < portfolio_full->trades().
size(); i++) {
133 BOOST_CHECK_CLOSE(portfolioFullIt->second->instrument()->NPV(), portfolioWCIt->second->instrument()->NPV(), 0.001);
134 portfolioFullIt++;
135 portfolioWCIt++;
136 }
137 }
138}
Size size(const ValueType &v)
vector< string > curveConfigs