Coverage Report

Created: 2026-06-08 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/time/calendars/canada.hpp
Line
Count
Source
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
 Copyright (C) 2007 StatPro Italia srl
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
/*! \file canada.hpp
22
    \brief Canadian calendar
23
*/
24
25
#ifndef quantlib_canadian_calendar_hpp
26
#define quantlib_canadian_calendar_hpp
27
28
#include <ql/time/calendar.hpp>
29
30
namespace QuantLib {
31
32
    //! Canadian calendar
33
    /*! Banking holidays
34
        (data from <http://www.bankofcanada.ca/en/about/holiday.html>):
35
        <ul>
36
        <li>Saturdays</li>
37
        <li>Sundays</li>
38
        <li>New Year's Day, January 1st (possibly moved to Monday)</li>
39
        <li>Family Day, third Monday of February (since 2008)</li>
40
        <li>Good Friday</li>
41
        <li>Victoria Day, the Monday on or preceding May 24th</li>
42
        <li>Canada Day, July 1st (possibly moved to Monday)</li>
43
        <li>Provincial Holiday, first Monday of August</li>
44
        <li>Labour Day, first Monday of September</li>
45
        <li>National Day for Truth and Reconciliation, September 30th (possibly moved to Monday)</li>
46
        <li>Thanksgiving Day, second Monday of October</li>
47
        <li>Remembrance Day, November 11th (possibly moved to Monday)</li>
48
        <li>Christmas, December 25th (possibly moved to Monday or Tuesday)</li>
49
        <li>Boxing Day, December 26th (possibly moved to Monday or
50
            Tuesday)</li>
51
        </ul>
52
53
        Holidays for the Toronto stock exchange
54
        (data from <http://www.tsx.com/en/about_tsx/market_hours.html>):
55
        <ul>
56
        <li>Saturdays</li>
57
        <li>Sundays</li>
58
        <li>New Year's Day, January 1st (possibly moved to Monday)</li>
59
        <li>Family Day, third Monday of February (since 2008)</li>
60
        <li>Good Friday</li>
61
        <li>Victoria Day, the Monday on or preceding May 24th</li>
62
        <li>Canada Day, July 1st (possibly moved to Monday)</li>
63
        <li>Provincial Holiday, first Monday of August</li>
64
        <li>Labour Day, first Monday of September</li>
65
        <li>Thanksgiving Day, second Monday of October</li>
66
        <li>Christmas, December 25th (possibly moved to Monday or Tuesday)</li>
67
        <li>Boxing Day, December 26th (possibly moved to Monday or
68
            Tuesday)</li>
69
        </ul>
70
71
        \ingroup calendars
72
    */
73
    class Canada : public Calendar {
74
      private:
75
        class SettlementImpl final : public Calendar::WesternImpl {
76
          public:
77
190
            std::string name() const override { return "Canada"; }
78
            bool isBusinessDay(const Date&) const override;
79
        };
80
        class TsxImpl final : public Calendar::WesternImpl {
81
          public:
82
0
            std::string name() const override { return "TSX"; }
83
            bool isBusinessDay(const Date&) const override;
84
        };
85
      public:
86
        enum Market { Settlement,       //!< generic settlement calendar
87
                      TSX               //!< Toronto stock exchange calendar
88
        };
89
        Canada(Market market = Settlement);
90
    };
91
92
}
93
94
95
#endif