Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
calendars.cpp File Reference
#include "toplevelfixture.hpp"
#include <boost/test/unit_test.hpp>
#include <qle/calendars/russia.hpp>
#include <qle/calendars/unitedarabemirates.hpp>
#include <ql/settings.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testRussiaModified)
 
 BOOST_AUTO_TEST_CASE (updatedArabEmirates)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( testRussiaModified  )

Definition at line 34 of file calendars.cpp.

34 {
35
36 BOOST_TEST_MESSAGE("Testing RussiaModified calendar");
37
38 Calendar russiaSettlement = Russia(Russia::Settlement);
39 Calendar russiaExchange = Russia(Russia::MOEX);
40 Calendar russiaModifiedSettlement = RussiaModified(Russia::Settlement);
41 Calendar russiaModifiedExchange = RussiaModified(Russia::MOEX);
42
43 // check that the new modified Russia exchange calendar does not throw before 2012
44 Date pre(31, December, 2011);
45 BOOST_CHECK_THROW(russiaExchange.isBusinessDay(pre), QuantLib::Error);
46 BOOST_CHECK_NO_THROW(russiaModifiedExchange.isBusinessDay(pre));
47
48 // before 2012: The new modifed Russia exchange calendar uses QuantLib's Russia settlement
49 Date start2011(1, Jan, 2011);
50 Date end2011(31, Dec, 2011);
51 for(Date d = start2011; d <= end2011; d++) {
52 BOOST_CHECK_EQUAL(russiaSettlement.isBusinessDay(d), russiaModifiedSettlement.isBusinessDay(d));
53 BOOST_CHECK_EQUAL(russiaSettlement.isBusinessDay(d), russiaModifiedExchange.isBusinessDay(d));
54 }
55
56 // 2012 onwards: The new modifed Russia exchange calendar matches uses QuantLib's Russia exchange
57 Date start2012(1, Jan, 2012);
58 Date end2012(31, Dec, 2012);
59 for(Date d = start2012; d <= end2012; d++) {
60 BOOST_CHECK_EQUAL(russiaSettlement.isBusinessDay(d), russiaModifiedSettlement.isBusinessDay(d));
61 BOOST_CHECK_EQUAL(russiaExchange.isBusinessDay(d), russiaModifiedExchange.isBusinessDay(d));
62 }
63}
Russian calendars.
Definition: russia.hpp:37

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( updatedArabEmirates  )

Definition at line 65 of file calendars.cpp.

65 {
66 BOOST_TEST_MESSAGE("Testing updated UAE calendar");
67 Calendar UAE = UnitedArabEmirates();
68 std::vector<QuantLib::Date> testDates{
69 Date(4,Feb,2021),
70 Date(5,Feb,2021),
71 Date(6,Feb,2021),
72 Date(7,Feb,2021),
73 Date(8,Feb,2021),
74 Date(9,Feb,2021),
75 Date(10,Feb,2021),
76 Date(30,Dec,2021),
77 Date(31,Dec,2021),
78 Date(1,Jan,2022), // this is always holiday, but being Sat it serves the goal of the test
79 Date(2,Jan,2022),
80 Date(3,Jan,2022),
81 Date(4,Jan,2022),
82 Date(5,Jan,2022),
83 Date(4,Feb,2022),
84 Date(5,Feb,2022),
85 Date(6,Feb,2022),
86 Date(7,Feb,2022),
87 Date(8,Feb,2022),
88 Date(9,Feb,2022),
89 Date(10,Feb,2022),
90 };
91
92 for (auto d:testDates){
93 if(d.year()<2022)
94 switch (d.weekday()) {
95 case QuantLib::Friday:
96 case QuantLib::Saturday:
97 BOOST_TEST(!UAE.isBusinessDay(d));
98 break ;
99 default:
100 BOOST_TEST(UAE.isBusinessDay(d));
101 break ;
102 }
103 else{
104 switch (d.weekday()) {
105 case QuantLib::Saturday:
106 case QuantLib::Sunday:
107 BOOST_TEST(!UAE.isBusinessDay(d));
108 break ;
109 default:
110 BOOST_TEST(UAE.isBusinessDay(d));
111 break ;
112 }
113 }
114 }
115
116}
Islamic Weekends-only calendar.