20#include <boost/test/unit_test.hpp>
21#include <boost/test/data/test_case.hpp>
35#include <oret/datapaths.hpp>
36#include <oret/toplevelfixture.hpp>
38#include <boost/algorithm/string.hpp>
39#include <boost/make_shared.hpp>
43using namespace boost::unit_test_framework;
53struct TodaysMarketArguments {
55 TodaysMarketArguments(
const Date& asof,
const string& curveconfigFile)
58 Settings::instance().evaluationDate() = asof;
60 string filename =
"conventions.xml";
61 conventions->fromFile(TEST_INPUT_FILE(filename));
62 InstrumentConventions::instance().setConventions(conventions);
64 filename = curveconfigFile;
67 filename =
"todaysmarket.xml";
68 todaysMarketParameters->fromFile(TEST_INPUT_FILE(filename));
70 filename =
"market.txt";
71 string fixingsFilename =
"fixings.txt";
72 loader = QuantLib::ext::make_shared<CSVLoader>(TEST_INPUT_FILE(filename), TEST_INPUT_FILE(fixingsFilename),
false);
76 QuantLib::ext::shared_ptr<Conventions> conventions = QuantLib::ext::make_shared<Conventions>();
77 QuantLib::ext::shared_ptr<CurveConfigurations>
curveConfigs = QuantLib::ext::make_shared<CurveConfigurations>();
78 QuantLib::ext::shared_ptr<TodaysMarketParameters> todaysMarketParameters = QuantLib::ext::make_shared<TodaysMarketParameters>();
79 QuantLib::ext::shared_ptr<Loader> loader;
84BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
86BOOST_AUTO_TEST_SUITE(FxVolCurveTests)
90 BOOST_TEST_MESSAGE(
"Testing FxVolatility Curve Wildcards");
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" }
98 Date asof(31, Dec, 2018);
99 TodaysMarketArguments tma_full(asof, c.first);
100 TodaysMarketArguments tma_wc(asof, c.second);
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);
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);
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);
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);
127 BOOST_CHECK_EQUAL(portfolio_full->size(), portfolio_wc->size());
129 auto portfolioFullIt = portfolio_full->trades().begin();
130 auto portfolioWCIt = portfolio_wc->trades().begin();
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);
140BOOST_AUTO_TEST_SUITE_END()
142BOOST_AUTO_TEST_SUITE_END()
Engine builder for FX Options.
Market Datum Loader Implementation.
Market Datum Loader Interface.
Size size(const ValueType &v)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
vector< string > curveConfigs
BOOST_AUTO_TEST_CASE(testFxVolWildCards)
string conversion utilities
An concrete implementation of the Market class that loads todays market and builds the required curve...
base trade data model and serialization
Wrapper class for QuantLib term structures.