Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
peru.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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
20
21namespace QuantExt {
22
24 // all calendar instances share the same implementation instance
25 static QuantLib::ext::shared_ptr<Calendar::Impl> impl(new Peru::LseImpl);
26 impl_ = impl;
27}
28
29bool Peru::LseImpl::isBusinessDay(const Date& date) const {
30 Weekday w = date.weekday();
31 Day d = date.dayOfMonth(), dd = date.dayOfYear();
32 Month m = date.month();
33 Year y = date.year();
34 Day em = easterMonday(y);
35 if (isWeekend(w)
36 // New Years
37 || (d == 1 && m == January)
38 // if New Years on Thurs, get Fri off too
39 || (d == 2 && w == Friday && m == January)
40 // Maundy Thursday
41 || (dd == em - 4)
42 // Good Friday
43 || (dd == em - 3)
44 // Labour Day
45 || (d == 1 && m == May)
46 // Saint Peter and Saint Paul
47 || (d == 29 && m == June)
48 // Independence Day
49 || ((d == 28 || (d == 27 && w == Friday) || (d == 29 && w == Monday)) && m == July)
50 // if Ind Day on Thurs, get Fri off too
51 || (d == 29 && w == Friday && m == July)
52 // Santa Rosa de Lima
53 || (d == 30 && m == August)
54 // if SR on Thurs, get Fri off too
55 || (d == 31 && w == Friday && m == August)
56 // Battle of Angamos
57 || (d == 8 && m == October)
58 // All Saints Day
59 || (d == 1 && m == November)
60 // if Saints Day on Thurs, get Fri off too
61 || (d == 2 && w == Friday && m == November)
62 // Immaculate Conception
63 || (d == 8 && m == December)
64 // Christmas
65 || (d == 25 && m == December))
66 return false;
67 return true;
68}
69
70} // namespace QuantExt
bool isBusinessDay(const Date &) const override
Definition: peru.cpp:29
Peru(Market m=LSE)
Definition: peru.cpp:23
Peru calendar.