Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
fxvolcurve.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <ored/marketdata/csvloader.hpp>
#include <ored/marketdata/loader.hpp>
#include <ored/marketdata/marketdatumparser.hpp>
#include <ored/portfolio/builders/fxoption.hpp>
#include <ored/portfolio/trade.hpp>
#include <ored/marketdata/todaysmarket.hpp>
#include <ored/marketdata/yieldcurve.hpp>
#include <ored/portfolio/enginefactory.hpp>
#include <ored/portfolio/portfolio.hpp>
#include <ored/utilities/parsers.hpp>
#include <ored/utilities/to_string.hpp>
#include <oret/datapaths.hpp>
#include <oret/toplevelfixture.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/make_shared.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testFxVolWildCards)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( testFxVolWildCards  )

Definition at line 88 of file fxvolcurve.cpp.

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
97 for (auto& c : curveConfigs) {
98 Date asof(31, Dec, 2018);
99 TodaysMarketArguments tma_full(asof, c.first);
100 TodaysMarketArguments tma_wc(asof, c.second);
101
102 // Check that the market builds without error.
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 // Portfolio containing 2 AU CPI zero coupon swaps, AUD 10M, that should price at 0, i.e. NPV < AUD 0.01.
109 // Similar to the fixing file, the helpers on the release date depend on the publication roll setting.
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)
Definition: value.cpp:145
vector< string > curveConfigs
+ Here is the call graph for this function: