20#include <boost/test/unit_test.hpp>
21#include <boost/test/data/test_case.hpp>
23#include <oret/datapaths.hpp>
24#include <oret/toplevelfixture.hpp>
26#include <boost/make_shared.hpp>
35using namespace boost::unit_test_framework;
44QuantLib::ext::shared_ptr<TodaysMarket> createTodaysMarket(
const Date& asof,
const string& inputDir) {
46 auto conventions = QuantLib::ext::make_shared<Conventions>();
48 InstrumentConventions::instance().setConventions(conventions);
50 auto curveConfigs = QuantLib::ext::make_shared<CurveConfigurations>();
51 curveConfigs->fromFile(TEST_INPUT_FILE(
string(inputDir +
"/curveconfig.xml")));
53 auto todaysMarketParameters = QuantLib::ext::make_shared<TodaysMarketParameters>();
54 todaysMarketParameters->fromFile(TEST_INPUT_FILE(
string(inputDir +
"/todaysmarket.xml")));
56 auto loader = QuantLib::ext::make_shared<CSVLoader>(TEST_INPUT_FILE(
string(inputDir +
"/market.txt")),
57 TEST_INPUT_FILE(
string(inputDir +
"/fixings.txt")),
false);
59 return QuantLib::ext::make_shared<TodaysMarket>(asof, todaysMarketParameters, loader,
curveConfigs);
64BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
66BOOST_AUTO_TEST_SUITE(BaseCorrelationCurveTests)
70 "exp_terms_exp_dps_curve",
71 "exp_terms_exp_dps_surface",
72 "exp_terms_wc_dps_curve",
73 "exp_terms_wc_dps_surface",
74 "wc_terms_exp_dps_curve",
75 "wc_terms_exp_dps_surface",
76 "wc_terms_wc_dps_curve",
77 "wc_terms_wc_dps_surface"
82 BOOST_TEST_MESSAGE(
"Testing base correlation structure building using setup in " << setup);
84 Date asof(19, Oct, 2020);
85 Settings::instance().evaluationDate() = asof;
87 auto todaysMarket = createTodaysMarket(asof, setup);
90 auto bc = todaysMarket->baseCorrelation(
"BASE_CORR_TEST");
94 BusinessDayConvention bdc = Following;
100 string filename = setup +
"/expected.csv";
102 BOOST_REQUIRE_EQUAL(reader.numberOfColumns(), 3);
104 BOOST_TEST_MESSAGE(
"term,detachment,expected_bc,calculated_bc,difference");
105 while (reader.next()) {
113 Date d =
calendar.advance(asof, term, bdc);
114 Real calcBc = bc->correlation(d, dp);
115 Real difference = expBc - calcBc;
116 BOOST_TEST_MESSAGE(term <<
"," << fixed << setprecision(12) << dp <<
"," <<
117 expBc <<
"," << calcBc <<
"," << difference);
118 BOOST_CHECK_SMALL(difference, tol);
122BOOST_AUTO_TEST_SUITE_END()
124BOOST_AUTO_TEST_SUITE_END()
utility class to access CSV files
Market Datum Loader Implementation.
Curve configuration repository.
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Real parseReal(const string &s)
Convert text to Real.
Map text representations to QuantLib/QuantExt types.
BOOST_DATA_TEST_CASE(testMartingaleProperty, bdata::make(driftFreeState) *bdata::make(steps), driftFreeState, steps)
vector< string > curveConfigs
An concrete implementation of the Market class that loads todays market and builds the required curve...