Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
calendaradjustment.cpp File Reference
#include <algorithm>
#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <ored/marketdata/csvloader.hpp>
#include <ored/utilities/calendaradjustmentconfig.hpp>
#include <ored/utilities/csvfilereader.hpp>
#include <ored/utilities/parsers.hpp>
#include <ored/utilities/to_string.hpp>
#include <oret/datapaths.hpp>
#include <oret/toplevelfixture.hpp>
#include <ql/time/date.hpp>
#include <string>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testCalendarAdjustmentRealCalendars)
 
 BOOST_AUTO_TEST_CASE (testCalendarAdjustment)
 
 BOOST_AUTO_TEST_CASE (testInvalidCalendarAdjustment)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( testCalendarAdjustmentRealCalendars  )

Definition at line 105 of file calendaradjustment.cpp.

105 {
106 // loop over expected holidays, for each calendar call parseCalendar()
107 // and check that the holidays match the expected ones
108 for (auto expectedHolidays : loadExpectedHolidays()) {
109 vector<Date> qcalHols;
110 qcalHols = parseCalendar(expectedHolidays.calendarName).holidayList(startDate, endDate, false);
111 BOOST_CHECK_EQUAL_COLLECTIONS(qcalHols.begin(), qcalHols.end(), expectedHolidays.holidays.begin(),
112 expectedHolidays.holidays.end());
113 }
114}
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( testCalendarAdjustment  )

Definition at line 116 of file calendaradjustment.cpp.

116 {
117 BOOST_TEST_MESSAGE("Testing calendar adjustments...");
118
121 BOOST_REQUIRE(cac.getCalendars().empty());
122
123 // adding UK holiday not in Quantlib calendar
124 cac.addHolidays("UK", Date(29, April, 2011));
125 // Checking that we get it back
126 // Note getCalenders get the quantlib name
127 BOOST_REQUIRE(cac.getCalendars() == set<string>({"UK settlement"}));
128
129 BOOST_REQUIRE(cac.getHolidays("UK") == set<Date>({Date(29, April, 2011)}));
130 BOOST_REQUIRE(cac.getBusinessDays("UK").empty());
131
132 cac.addBusinessDays("UK", Date(25, December, 2011));
133 BOOST_REQUIRE(cac.getBusinessDays("UK") == set<Date>({Date(25, December, 2011)}));
134 cac.addHolidays("UK", Date(25, December, 2011));
135
136 cacad.addHolidays("JPY", Date(1, May, 2019));
137 cac.append(cacad);
138 set<string> expcal = {"Japan", "UK settlement"};
139 set<string> res = {cac.getCalendars()};
140 BOOST_CHECK_EQUAL_COLLECTIONS(res.begin(), res.end(), expcal.begin(), expcal.end());
141 BOOST_REQUIRE(cac.getHolidays("JPY") == set<Date>({Date(1, May, 2019)}));
142}
const set< Date > & getHolidays(const string &calname) const
Returns all the holidays for a given cal name.
void addBusinessDays(const string &calname, const Date &d)
This method adds d to the list of business days for cal name.
const set< Date > & getBusinessDays(const string &calname) const
Returns all the business days for a given calname.
void addHolidays(const string &calname, const Date &d)
This method adds d to the list of holidays for cal name.
void append(const CalendarAdjustmentConfig &c)
add all holidays and business days from c to this instance
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( testInvalidCalendarAdjustment  )

Definition at line 144 of file calendaradjustment.cpp.

144 {
145 BOOST_TEST_MESSAGE("Testing that incorrect CalendarAdjustments are not accepted...");
146
147 // we check that new calendars can't be declared using another new calendar as a base
148 CalendarAdjustmentConfig calendarAdjustments_1;
149 BOOST_CHECK_THROW(calendarAdjustments_1.fromFile(TEST_INPUT_FILE("invalid_calendaradjustments_1.xml")), QuantLib::Error);
150}
void fromFile(const std::string &filename)
Definition: xmlutils.cpp:150
+ Here is the call graph for this function: