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>
31using namespace boost::unit_test_framework;
45 "ice_wti_midland_basis",
54BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
56BOOST_AUTO_TEST_SUITE(ConventionsBasedFutureExpiryTests)
60 BOOST_TEST_MESSAGE(
"Testing expiry dates for commodity: " << commodityName);
64 string filename = commodityName +
"_conventions.xml";
65 conventions.
fromFile(TEST_INPUT_FILE(filename));
68 BOOST_TEST_REQUIRE(conventions.
has(commodityName));
69 auto convention = QuantLib::ext::dynamic_pointer_cast<CommodityFutureConvention>(conventions.
get(commodityName));
70 BOOST_TEST_REQUIRE(convention);
74 filename = commodityName +
"_expiries.csv";
78 while (reader.
next()) {
85 Date expiryDate = cbfe.
expiryDate(contractDate, 0);
88 BOOST_CHECK_EQUAL(expExpiryDate, expiryDate);
91 string strExpOptionExpiry = reader.
get(2);
92 if (!strExpOptionExpiry.empty()) {
95 Date expOptionExpiry =
parseDate(strExpOptionExpiry);
98 Date optionExpiry = cbfe.
expiryDate(contractDate, 0,
true);
100 BOOST_CHECK_EQUAL(expOptionExpiry, optionExpiry);
105BOOST_AUTO_TEST_SUITE_END()
107BOOST_AUTO_TEST_SUITE_END()
Size numberOfColumns() const
std::string get(const std::string &field) const
Perform date calculations for future contracts based on conventions.
QuantLib::Date expiryDate(const QuantLib::Date &contractDate, QuantLib::Natural monthOffset=0, bool forOption=false) override
Repository for currency dependent market conventions.
bool has(const std::string &id) const
Checks if we have a convention with the given id.
QuantLib::ext::shared_ptr< Convention > get(const string &id) const
void fromFile(const std::string &filename)
Base class for classes that perform date calculations for future contracts.
utility class to access CSV files
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Map text representations to QuantLib/QuantExt types.
vector< string > commodityNames
BOOST_DATA_TEST_CASE(testExpiryDates, bdata::make(commodityNames), commodityName)