QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
france.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004 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/france.hpp>
21#include <ql/errors.hpp>
22
23namespace QuantLib {
24
26 // all calendar instances on the same market share the same
27 // implementation instance
28 static ext::shared_ptr<Calendar::Impl> settlementImpl(
30 static ext::shared_ptr<Calendar::Impl> exchangeImpl(
32 switch (market) {
33 case Settlement:
34 impl_ = settlementImpl;
35 break;
36 case Exchange:
37 impl_ = exchangeImpl;
38 break;
39 default:
40 QL_FAIL("unknown market");
41 }
42 }
43
44
46 Weekday w = date.weekday();
47 Day d = date.dayOfMonth(), dd = date.dayOfYear();
48 Month m = date.month();
49 Year y = date.year();
50 Day em = easterMonday(y);
51 if (isWeekend(w)
52 // Jour de l'An
53 || (d == 1 && m == January)
54 // Lundi de Paques
55 || (dd == em)
56 // Fete du Travail
57 || (d == 1 && m == May)
58 // Victoire 1945
59 || (d == 8 && m == May)
60 // Ascension
61 || (d == 10 && m == May)
62 // Pentecote
63 || (d == 21 && m == May)
64 // Fete nationale
65 || (d == 14 && m == July)
66 // Assomption
67 || (d == 15 && m == August)
68 // Toussaint
69 || (d == 1 && m == November)
70 // Armistice 1918
71 || (d == 11 && m == November)
72 // Noel
73 || (d == 25 && m == December))
74
75 return false; // NOLINT(readability-simplify-boolean-expr)
76 return true;
77 }
78
79
80 bool France::ExchangeImpl::isBusinessDay(const Date& date) const {
81 Weekday w = date.weekday();
82 Day d = date.dayOfMonth(), dd = date.dayOfYear();
83 Month m = date.month();
84 Year y = date.year();
85 Day em = easterMonday(y);
86 if (isWeekend(w)
87 // Jour de l'An
88 || (d == 1 && m == January)
89 // Good Friday
90 || (dd == em-3)
91 // Easter Monday
92 || (dd == em)
93 // Labor Day
94 || (d == 1 && m == May)
95 // Christmas Eve
96 || (d == 24 && m == December)
97 // Christmas Day
98 || (d == 25 && m == December)
99 // Boxing Day
100 || (d == 26 && m == December)
101 // New Year's Eve
102 || (d == 31 && m == December))
103
104 return false; // NOLINT(readability-simplify-boolean-expr)
105 return true;
106 }
107
108}
109
static Day easterMonday(Year)
expressed relative to first day of year
Definition: calendar.cpp:193
bool isWeekend(Weekday) const override
Definition: calendar.cpp:189
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
bool isBusinessDay(const Date &) const override
Definition: france.cpp:80
bool isBusinessDay(const Date &) const override
Definition: france.cpp:45
France(Market market=Settlement)
Definition: france.cpp:25
Market
French calendars.
Definition: france.hpp:80
@ Settlement
generic settlement calendar
Definition: france.hpp:80
@ Exchange
Paris stock-exchange calendar.
Definition: france.hpp:81
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
@ July
Definition: date.hpp:63
@ May
Definition: date.hpp:61
@ November
Definition: date.hpp:67
Definition: any.hpp:35