QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
australia.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
21
22namespace QuantLib {
23
25 // all calendar instances share the same implementation instance
26 static ext::shared_ptr<Calendar::Impl> settlementImpl(
28 static ext::shared_ptr<Calendar::Impl> asxImpl(
30 switch (market) {
31 case Settlement:
32 impl_ = settlementImpl;
33 break;
34 case ASX:
35 impl_ = asxImpl;
36 break;
37 default:
38 QL_FAIL("unknown market");
39 }
40 }
41
43 Weekday w = date.weekday();
44 Day d = date.dayOfMonth(), dd = date.dayOfYear();
45 Month m = date.month();
46 Year y = date.year();
47 Day em = easterMonday(y);
48 if (isWeekend(w)
49 // New Year's Day (possibly moved to Monday)
50 || ((d == 1 || ((d == 2 || d == 3) && w == Monday)) && m == January)
51 // Australia Day, January 26th (possibly moved to Monday)
52 || ((d == 26 || ((d == 27 || d == 28) && w == Monday)) &&
53 m == January)
54 // Good Friday
55 || (dd == em-3)
56 // Easter Monday
57 || (dd == em)
58 // ANZAC Day, April 25th
59 || (d == 25 && m == April)
60 // Queen's Birthday, second Monday in June
61 || ((d > 7 && d <= 14) && w == Monday && m == June)
62 // Bank Holiday, first Monday in August
63 || (d <= 7 && w == Monday && m == August)
64 // Labour Day, first Monday in October
65 || (d <= 7 && w == Monday && m == October)
66 // Christmas, December 25th (possibly Monday or Tuesday)
67 || ((d == 25 || (d == 27 && (w == Monday || w == Tuesday)))
68 && m == December)
69 // Boxing Day, December 26th (possibly Monday or Tuesday)
70 || ((d == 26 || (d == 28 && (w == Monday || w == Tuesday)))
71 && m == December)
72 // National Day of Mourning for Her Majesty, September 22 (only 2022)
73 || (d == 22 && m == September && y == 2022))
74 return false; // NOLINT(readability-simplify-boolean-expr)
75 return true;
76 }
77
78 bool Australia::AsxImpl::isBusinessDay(const Date& date) const {
79 Weekday w = date.weekday();
80 Day d = date.dayOfMonth(), dd = date.dayOfYear();
81 Month m = date.month();
82 Year y = date.year();
83 Day em = easterMonday(y);
84 if (isWeekend(w)
85 // New Year's Day (possibly moved to Monday)
86 || ((d == 1 || ((d == 2 || d == 3) && w == Monday)) && m == January)
87 // Australia Day, January 26th (possibly moved to Monday)
88 || ((d == 26 || ((d == 27 || d == 28) && w == Monday)) &&
89 m == January)
90 // Good Friday
91 || (dd == em-3)
92 // Easter Monday
93 || (dd == em)
94 // ANZAC Day, April 25th
95 || (d == 25 && m == April)
96 // Queen's Birthday, second Monday in June
97 || ((d > 7 && d <= 14) && w == Monday && m == June)
98 // Christmas, December 25th (possibly Monday or Tuesday)
99 || ((d == 25 || (d == 27 && (w == Monday || w == Tuesday)))
100 && m == December)
101 // Boxing Day, December 26th (possibly Monday or Tuesday)
102 || ((d == 26 || (d == 28 && (w == Monday || w == Tuesday)))
103 && m == December)
104 // National Day of Mourning for Her Majesty, September 22 (only 2022)
105 || (d == 22 && m == September && y == 2022))
106 return false; // NOLINT(readability-simplify-boolean-expr)
107 return true;
108 }
109
110}
Australian calendar.
bool isBusinessDay(const Date &) const override
Definition: australia.cpp:78
bool isBusinessDay(const Date &) const override
Definition: australia.cpp:42
@ ASX
Australia ASX calendar.
Definition: australia.hpp:66
@ Settlement
generic settlement calendar
Definition: australia.hpp:65
Australia(Market market=Settlement)
Definition: australia.cpp:24
static Day easterMonday(Year)
expressed relative to first day of year
Definition: calendar.cpp:199
bool isWeekend(Weekday) const override
Definition: calendar.cpp:195
bool isWeekend(Weekday w) const
Definition: calendar.hpp:255
ext::shared_ptr< Impl > impl_
Definition: calendar.hpp:72
Concrete date class.
Definition: date.hpp:125
Month month() const
Definition: date.cpp:82
Year year() const
Definition: date.cpp:93
Day dayOfMonth() const
Definition: date.hpp:400
Weekday weekday() const
Definition: date.hpp:395
Day dayOfYear() const
One-based (Jan 1st = 1)
Definition: date.hpp:404
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
Date d
Integer Year
Year number.
Definition: date.hpp:87
Integer Day
Day number.
Definition: date.hpp:53
Month
Month names.
Definition: date.hpp:57
@ December
Definition: date.hpp:68
@ August
Definition: date.hpp:64
@ January
Definition: date.hpp:57
@ April
Definition: date.hpp:60
@ October
Definition: date.hpp:66
@ June
Definition: date.hpp:62
@ September
Definition: date.hpp:65
@ Monday
Definition: weekday.hpp:42
@ Tuesday
Definition: weekday.hpp:43
Definition: any.hpp:35