20#include <boost/test/unit_test.hpp>
21#include <boost/test/data/test_case.hpp>
33#include <oret/datapaths.hpp>
34#include <oret/toplevelfixture.hpp>
36#include <boost/algorithm/string.hpp>
37#include <boost/make_shared.hpp>
41using namespace boost::unit_test_framework;
51struct TodaysMarketArguments {
53 TodaysMarketArguments(
const Date& asof,
const string& inputDir,
const string& marketFile,
54 const string& fixingsFile,
const string& conventionsFile)
57 Settings::instance().evaluationDate() = asof;
59 string filename = inputDir +
"/" + conventionsFile;
60 conventions->fromFile(TEST_INPUT_FILE(filename));
61 InstrumentConventions::instance().setConventions(conventions);
63 filename = inputDir +
"/curveconfig.xml";
66 filename = inputDir +
"/todaysmarket.xml";
67 todaysMarketParameters->fromFile(TEST_INPUT_FILE(filename));
69 filename = inputDir +
"/" + marketFile;
70 string fixingsFilename = inputDir +
"/" + fixingsFile;
71 loader = QuantLib::ext::make_shared<CSVLoader>(TEST_INPUT_FILE(filename), TEST_INPUT_FILE(fixingsFilename),
false);
75 QuantLib::ext::shared_ptr<Conventions> conventions = QuantLib::ext::make_shared<Conventions>();
76 QuantLib::ext::shared_ptr<CurveConfigurations>
curveConfigs = QuantLib::ext::make_shared<CurveConfigurations>();
77 QuantLib::ext::shared_ptr<TodaysMarketParameters> todaysMarketParameters = QuantLib::ext::make_shared<TodaysMarketParameters>();
78 QuantLib::ext::shared_ptr<Loader> loader;
83BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
85BOOST_AUTO_TEST_SUITE(InflationCurveTests)
90vector<Date> auCpiTestDates{
96vector<string> publicationRolls{
101BOOST_DATA_TEST_CASE(testAuCpiZcInflationCurve, bdata::make(auCpiTestDates) * bdata::make(publicationRolls),
102 asof, publicationRoll) {
104 BOOST_TEST_MESSAGE(
"Testing AU CPI zero coupon inflation curve bootstrap on date " << io::iso_date(asof));
107 string marketFile =
"market_" +
to_string(io::iso_date(asof)) +
".txt";
108 string fixingsFile =
"fixings_" +
to_string(io::iso_date(asof));
109 if (asof == Date(28, Oct, 2020)) {
110 fixingsFile +=
"_" + publicationRoll;
112 fixingsFile +=
".txt";
113 string conventionsFile =
"conventions_" + publicationRoll +
".xml";
114 TodaysMarketArguments tma(asof,
"aucpi_zc", marketFile, fixingsFile, conventionsFile);
117 QuantLib::ext::shared_ptr<TodaysMarket> market;
118 BOOST_REQUIRE_NO_THROW(market = QuantLib::ext::make_shared<TodaysMarket>(tma.asof, tma.todaysMarketParameters,
119 tma.loader, tma.curveConfigs,
false,
true,
false));
123 string portfolioFile =
"aucpi_zc/portfolio_" +
to_string(io::iso_date(asof));
124 if (asof == Date(28, Oct, 2020)) {
125 portfolioFile +=
"_" + publicationRoll;
127 portfolioFile +=
".xml";
129 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
130 engineData->fromFile(TEST_INPUT_FILE(
"aucpi_zc/pricingengine.xml"));
131 QuantLib::ext::shared_ptr<EngineFactory> factory = QuantLib::ext::make_shared<EngineFactory>(engineData, market);
132 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
133 portfolio->fromFile(TEST_INPUT_FILE(portfolioFile));
134 portfolio->build(factory);
136 BOOST_CHECK_EQUAL(portfolio->size(), 2);
137 for (
const auto& [tradeId, trade] : portfolio->trades()) {
138 BOOST_CHECK_SMALL(trade->instrument()->NPV(), 0.01);
142BOOST_AUTO_TEST_SUITE_END()
144BOOST_AUTO_TEST_SUITE_END()
Market Datum Loader Implementation.
Market Datum Loader Interface.
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
BOOST_DATA_TEST_CASE(testMartingaleProperty, bdata::make(driftFreeState) *bdata::make(steps), driftFreeState, steps)
vector< string > curveConfigs
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.