/src/quantlib/ql/time/calendars/mexico.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2005 StatPro Italia srl |
5 | | Copyright (C) 2024 Skandinaviska Enskilda Banken AB (publ) |
6 | | |
7 | | This file is part of QuantLib, a free-software/open-source library |
8 | | for financial quantitative analysts and developers - http://quantlib.org/ |
9 | | |
10 | | QuantLib is free software: you can redistribute it and/or modify it |
11 | | under the terms of the QuantLib license. You should have received a |
12 | | copy of the license along with this program; if not, please email |
13 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
14 | | <https://www.quantlib.org/license.shtml>. |
15 | | |
16 | | This program is distributed in the hope that it will be useful, but WITHOUT |
17 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
18 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
19 | | */ |
20 | | |
21 | | #include <ql/time/calendars/mexico.hpp> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | 0 | Mexico::Mexico(Market) { |
26 | | // all calendar instances share the same implementation instance |
27 | 0 | static ext::shared_ptr<Calendar::Impl> impl(new Mexico::BmvImpl); |
28 | 0 | impl_ = impl; |
29 | 0 | } |
30 | | |
31 | 0 | bool Mexico::BmvImpl::isBusinessDay(const Date& date) const { |
32 | 0 | Weekday w = date.weekday(); |
33 | 0 | Day d = date.dayOfMonth(), dd = date.dayOfYear(); |
34 | 0 | Month m = date.month(); |
35 | 0 | Year y = date.year(); |
36 | 0 | Day em = easterMonday(y); |
37 | 0 | if (isWeekend(w) |
38 | | // New Year's Day |
39 | 0 | || (d == 1 && m == January) |
40 | | // Constitution Day |
41 | 0 | || (y <= 2005 && d == 5 && m == February) |
42 | 0 | || (y >= 2006 && d <= 7 && w == Monday && m == February) |
43 | | // Birthday of Benito Juarez |
44 | 0 | || (y <= 2005 && d == 21 && m == March) |
45 | 0 | || (y >= 2006 && (d >= 15 && d <= 21) && w == Monday && m == March) |
46 | | // Holy Thursday |
47 | 0 | || (dd == em-4) |
48 | | // Good Friday |
49 | 0 | || (dd == em-3) |
50 | | // Labour Day |
51 | 0 | || (d == 1 && m == May) |
52 | | // National Day |
53 | 0 | || (d == 16 && m == September) |
54 | | // Inauguration Day |
55 | 0 | || (d == 1 && m == October && y >= 2024 && (y - 2024) % 6 == 0) |
56 | | // All Souls Day |
57 | 0 | || (d == 2 && m == November) |
58 | | // Revolution Day |
59 | 0 | || (y <= 2005 && d == 20 && m == November) |
60 | 0 | || (y >= 2006 && (d >= 15 && d <= 21) && w == Monday && m == November) |
61 | | // Our Lady of Guadalupe |
62 | 0 | || (d == 12 && m == December) |
63 | | // Christmas |
64 | 0 | || (d == 25 && m == December)) |
65 | 0 | return false; // NOLINT(readability-simplify-boolean-expr) |
66 | 0 | return true; |
67 | 0 | } |
68 | | |
69 | | } |
70 | | |