QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
mexico.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2005 StatPro Italia 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
20#include <ql/time/calendars/mexico.hpp>
21
22namespace QuantLib {
23
25 // all calendar instances share the same implementation instance
26 static ext::shared_ptr<Calendar::Impl> impl(new Mexico::BmvImpl);
27 impl_ = impl;
28 }
29
30 bool Mexico::BmvImpl::isBusinessDay(const Date& date) const {
31 Weekday w = date.weekday();
32 Day d = date.dayOfMonth(), dd = date.dayOfYear();
33 Month m = date.month();
34 Year y = date.year();
35 Day em = easterMonday(y);
36 if (isWeekend(w)
37 // New Year's Day
38 || (d == 1 && m == January)
39 // Constitution Day
40 || (y <= 2005 && d == 5 && m == February)
41 || (y >= 2006 && d <= 7 && w == Monday && m == February)
42 // Birthday of Benito Juarez
43 || (y <= 2005 && d == 21 && m == March)
44 || (y >= 2006 && (d >= 15 && d <= 21) && w == Monday && m == March)
45 // Holy Thursday
46 || (dd == em-4)
47 // Good Friday
48 || (dd == em-3)
49 // Labour Day
50 || (d == 1 && m == May)
51 // National Day
52 || (d == 16 && m == September)
53 // All Souls Day
54 || (d == 2 && m == November)
55 // Revolution Day
56 || (y <= 2005 && d == 20 && m == November)
57 || (y >= 2006 && (d >= 15 && d <= 21) && w == Monday && m == November)
58 // Our Lady of Guadalupe
59 || (d == 12 && m == December)
60 // Christmas
61 || (d == 25 && m == December))
62 return false; // NOLINT(readability-simplify-boolean-expr)
63 return true;
64 }
65
66}
67
static Day easterMonday(Year)
expressed relative to first day of year
Definition: calendar.cpp:193
bool isWeekend(Weekday) const override
Definition: calendar.cpp:189
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
bool isBusinessDay(const Date &) const override
Definition: mexico.cpp:30
Mexico(Market m=BMV)
Definition: mexico.cpp:24
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
@ January
Definition: date.hpp:57
@ May
Definition: date.hpp:61
@ March
Definition: date.hpp:59
@ February
Definition: date.hpp:58
@ November
Definition: date.hpp:67
@ September
Definition: date.hpp:65
@ Monday
Definition: weekday.hpp:42
Definition: any.hpp:35