Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
schedule.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <ored/portfolio/schedule.hpp>
#include <oret/toplevelfixture.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testScheduleData)
 
 BOOST_AUTO_TEST_CASE (testLastWednesdayDateGenerationRule)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( testScheduleData  )

Definition at line 31 of file schedule.cpp.

31 {
32
33 BOOST_TEST_MESSAGE("Testing ScheduleData...");
34
35 ScheduleDates dates1("TARGET", "", "", {"2015-01-09", "2015-02-09", "2015-03-09", "2015-04-09"});
36
37 ScheduleDates dates2("TARGET", "", "",
38 {"2015-04-09",
39 "2016-04-11", // 9th = Saturday
40 "2017-04-10", // 9th = Sunday
41 "2018-04-09"});
42
43 ScheduleRules rules1("2015-01-09", "2015-04-09", "1M", "TARGET", "MF", "MF", "Forward");
44
45 ScheduleRules rules2("2015-04-09", "2018-04-09", "1Y", "TARGET", "MF", "MF", "Forward");
46
47 // Test <Dates> and <Dates>
48 ScheduleData data(dates1);
49 data.addDates(dates2);
50 QuantLib::Schedule s = makeSchedule(data);
51 BOOST_CHECK_EQUAL(s.size(), 7UL); // 7 dates, 6 coupons
52 BOOST_CHECK_EQUAL(s.startDate(), Date(9, Jan, 2015));
53 BOOST_CHECK_EQUAL(s.endDate(), Date(9, Apr, 2018));
54
55 // Test <Rules> and <Rules>
56 data = ScheduleData(rules1);
57 data.addRules(rules2);
58 QuantLib::Schedule s2 = makeSchedule(data);
59 BOOST_CHECK_EQUAL(s2.size(), s.size());
60 for (Size i = 0; i < s.size(); i++)
61 BOOST_CHECK_EQUAL(s[i], s2[i]);
62
63 // Test <Dates> and <Rules>
64 data = ScheduleData(dates1);
65 data.addRules(rules2);
66 QuantLib::Schedule s3 = makeSchedule(data);
67 BOOST_CHECK_EQUAL(s3.size(), s.size());
68 for (Size i = 0; i < s.size(); i++)
69 BOOST_CHECK_EQUAL(s[i], s3[i]);
70}
Serializable schedule data.
Definition: schedule.hpp:202
Serializable object holding schedule Dates data.
Definition: schedule.hpp:110
Serializable object holding schedule Rules data.
Definition: schedule.hpp:37
@ data
Definition: log.hpp:77
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( testLastWednesdayDateGenerationRule  )

Definition at line 75 of file schedule.cpp.

75 {
76
77 vector<Date> expected{
78 Date(30, Oct, 2018),
79 Date(30, Jan, 2019), Date(24, Apr, 2019), Date(31, Jul, 2019), Date(30, Oct, 2019), // 2019
80 Date(29, Jan, 2020), Date(29, Apr, 2020), Date(29, Jul, 2020), Date(28, Oct, 2020), // 2020
81 Date(27, Jan, 2021), Date(28, Apr, 2021), Date(28, Jul, 2021), Date(27, Oct, 2021), // 2021
82 Date(25, Jan, 2022)
83 };
84
85 // AU CPI publication dates are the last Wednesday of Jan, Apr, Jul and Oct. If that is not a good AU business
86 // day, it is the preceding good AU business day.
87 Schedule s = makeSchedule(ScheduleData(ScheduleRules("2018-10-30", "2022-01-25", "3M", "AUD",
88 "Preceding", "Unadjusted", "LastWednesday")));
89
90 // Check
91 BOOST_CHECK_EQUAL_COLLECTIONS(s.dates().begin(), s.dates().end(), expected.begin(), expected.end());
92}
+ Here is the call graph for this function: