Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
calendars.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19// clang-format off
20#include <boost/test/unit_test.hpp>
21#include <boost/test/data/test_case.hpp>
22// clang-format on
24#include <oret/toplevelfixture.hpp>
25#include <ql/time/calendars/all.hpp>
26// #include <qle/calendars/austria.hpp>
29//#include <qle/calendars/chile.hpp>
30#include <qle/calendars/cme.hpp>
33#include <qle/calendars/ice.hpp>
41#include <qle/calendars/wmr.hpp>
42
43using namespace QuantLib;
44using namespace QuantExt;
45using namespace boost::unit_test_framework;
46using namespace std;
47
49
50using std::ostream;
51
52namespace {
53
54struct TestDatum {
55 const char* calendarName;
56 Calendar calendar;
57};
58
59// Needed for BOOST_DATA_TEST_CASE below as it writes out the TestDatum
60ostream& operator<<(ostream& os, const TestDatum& testDatum) {
61 return os << "[" << testDatum.calendarName << "," << testDatum.calendar.name() << "]";
62}
63
64TestDatum calendarData[] = {{"TGT", TARGET()},
65 {"EUR", TARGET()},
66 {"ATS", QuantExt::Austria()},
67 {"FRF", QuantExt::France()},
68 {"CHF", QuantExt::Switzerland()},
69 {"USD", UnitedStates(UnitedStates::Settlement)},
70 {"GBP", UnitedKingdom()},
71 {"CAD", Canada()},
72 {"AUD", Australia()},
73 {"JPY", Japan()},
74 {"ZAR", SouthAfrica()},
75 {"SEK", Sweden()},
76 {"ARS", Argentina()},
77 {"BWP", Botswana()},
78 {"BRL", Brazil()},
79 {"CNH", China()},
80 {"CNY", China()},
81 {"CZK", CzechRepublic()},
82 {"DKK", Denmark()},
83 {"FIN", Finland()},
84 {"HKD", HongKong()},
85 {"ISK", Iceland()},
86 {"INR", India()},
87 {"IDR", Indonesia()},
88 {"MXN", Mexico()},
89 {"NZD", NewZealand()},
90 {"NOK", Norway()},
91 {"PLN", Poland()},
92 {"RUB", Russia()},
93 {"SAR", SaudiArabia()},
94 {"SGD", Singapore()},
95 {"KRW", SouthKorea(SouthKorea::Settlement)},
96 {"TWD", Taiwan()},
97 {"TRY", Turkey()},
98 {"UAH", Ukraine()},
99 {"HUF", Hungary()},
100 // Emerging currencies that default to WeekendsOnly
101 {"CLP", Chile()},
102 {"COP", Colombia()},
103 {"ILS", Israel()},
104 {"MYR", Malaysia()},
105 {"PEN", Peru()},
106 {"PHP", Philippines()},
107 {"RON", Romania()},
108 {"THB", Thailand()},
109 {"CHF", QuantExt::Switzerland()},
110 {"ZA", SouthAfrica()},
111 {"MISX", RussiaModified(Russia::MOEX)},
113 {"XLON", UnitedKingdom(UnitedKingdom::Exchange)},
114 {"WMR", Wmr()},
115 {"LUX", Luxembourg()},
116 {"BEL", Belgium()},
117 {"ESP", Spain()},
118 {"AUT", Austria()},
119 // ICE exchange calendars
120 {"ICE_FuturesUS", ICE(ICE::FuturesUS)},
121 {"ICE_FuturesUS_1", ICE(ICE::FuturesUS_1)},
122 {"ICE_FuturesUS_2", ICE(ICE::FuturesUS_2)},
123 {"ICE_FuturesEU", ICE(ICE::FuturesEU)},
124 {"ICE_FuturesEU_1", ICE(ICE::FuturesEU_1)},
125 {"ICE_EndexEnergy", ICE(ICE::EndexEnergy)},
126 {"ICE_EndexEquities", ICE(ICE::EndexEquities)},
127 {"ICE_SwapTradeUS", ICE(ICE::SwapTradeUS)},
128 {"ICE_SwapTradeUK", ICE(ICE::SwapTradeUK)},
129 {"ICE_FuturesSingapore", ICE(ICE::FuturesSingapore)},
130 // CME exchange calendar
131 {"CME", CME()},
132 // joint calendars
133 {"US,TARGET", JointCalendar(UnitedStates(UnitedStates::Settlement), TARGET())},
134 {"NYB,TGT", JointCalendar(UnitedStates(UnitedStates::Settlement), TARGET())},
135 {"NYB,LNB", JointCalendar(UnitedStates(UnitedStates::Settlement), UnitedKingdom())},
136 {"LNB,ZUB", JointCalendar(UnitedKingdom(), QuantExt::Switzerland())},
137 {"LNB,NYB,TGT", JointCalendar(UnitedKingdom(), UnitedStates(UnitedStates::Settlement), TARGET())},
138 {"NYB,ZUB,LNB", JointCalendar(UnitedStates(UnitedStates::Settlement), QuantExt::Switzerland(), UnitedKingdom())},
139 {"NYB,TRB,LNB", JointCalendar(UnitedStates(UnitedStates::Settlement), Canada(), UnitedKingdom())},
140 {"TKB,USD,LNB", JointCalendar(Japan(), UnitedStates(UnitedStates::Settlement), UnitedKingdom())},
141 {"NYB,SYB", JointCalendar(UnitedStates(UnitedStates::Settlement), Australia())}};
142
143} // namespace
144
145BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
146
147BOOST_AUTO_TEST_SUITE(CalendarTests)
148
149BOOST_DATA_TEST_CASE(testCalendarNameParsing, bdata::make(calendarData), calendarDatum) {
150
151 Calendar calendar;
152 BOOST_REQUIRE_NO_THROW(calendar = ore::data::parseCalendar(calendarDatum.calendarName));
153 BOOST_REQUIRE(!calendar.empty());
154 BOOST_CHECK_EQUAL(calendar, calendarDatum.calendar);
155
156 BOOST_TEST_MESSAGE("Parsed " << calendarDatum.calendarName << " and got " << calendar.name());
157}
158
159BOOST_AUTO_TEST_SUITE_END()
160
161BOOST_AUTO_TEST_SUITE_END()
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
Calendar calendar
Definition: utilities.cpp:441
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
Map text representations to QuantLib/QuantExt types.
BOOST_DATA_TEST_CASE(testMartingaleProperty, bdata::make(driftFreeState) *bdata::make(steps), driftFreeState, steps)