1
2# This R package is free software; you can redistribute it and/or
3# modify it under the terms of the GNU Library General Public
4# License as published by the Free Software Foundation; either
5# version 2 of the License, or (at your option) any later version.
6#
7# This R package is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Library General Public License for more details.
11#
12# You should have received a copy of the GNU Library General
13# Public License along with this R package; if not, write to the
14# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15# MA  02111-1307  USA
16
17
18################################################################################
19# FUNCTION:                 DESCRIPTION:
20#  holidayTSX                Returns holidays for TSX calendar
21################################################################################
22
23# ---------------------------------------------------------------------------- #
24# Roxygen Tags
25#' @export
26# ---------------------------------------------------------------------------- #
27holidayTSX <-
28    function (year = getRmetricsOptions("currentYear"))
29{
30    # A function implemented by Diethelm Wuertz
31
32    # Description:
33    #   TSX Holiday Calendar
34
35    # In Canada, the first Monday in August is generally a holiday but it
36    # is known by different names in different areas. In Rmetrics it is
37    # called CACivicProvincialHoliday()
38
39    # TSX Holidays:
40    # http://www.tsx.com/en/market_activity/market_hours.html
41    #
42    #    * 2007:
43    #    * New Year's Day - January 1, 2007
44    #    * Good Friday - April 6, 2007
45    #    * Victoria Day - May 21, 2007
46    #    * Canada Day - July 2, 2007 (for July 1 holiday)
47    #    * Civic Day - August 6, 2007
48    #    * Labour Day - September 3, 2007
49    #    * Thanksgiving Day - October 8, 2007
50    #    * Christmas Eve - markets close at 1:00 p.m. ET
51    #    * Christmas Day - December 25, 2007
52    #    * Boxing Day - December 26, 2007
53    #
54    #    * 2008:
55    #    * New Year's Day - January 1, 2008
56    #    * Family Day - February 18, 2008
57    #    * Good Friday - March 21, 2008
58    #    * Victoria Day - May 19, 2008
59    #    * Canada Day - July 1, 2008
60    #    * Civic Day - August 4, 2008
61    #    * Labour Day - September 1, 2008
62    #    * Thanksgiving Day - October 13, 2008
63    #    * Christmas Day - December 25, 2008
64    #    * Boxing Day - December 26, 2008
65
66    # Trading Hours:
67    #   Toronto Stock Exchange and TSX Venture Exchange have trading hours
68    #   of 9:30 a.m. to 4:00 p.m. ET, Monday to Friday, with the exception
69    #   of the stock market holidays listed below. There is also an extended
70    #   session for market participants (Participating Organizations and Members)
71    #   from 4:15 to 5:00 p.m. ET each trading day.
72
73    # FUNCTION:
74
75    # Holidays - Years before 2007 are not checked out ...
76    holidays = c(
77        NewYearsDay(year),
78        GoodFriday(year),
79        CAVictoriaDay(year),
80        CACanadaDay(year),
81        CACivicProvincialHoliday(year),
82        CAThanksgivingDay(year),
83        ChristmasDay(year),
84        BoxingDay(year))
85    for (y in year)
86        if (y >= 2008) holidays = c(holidays, CAFamilyDay(year))
87    holidays = sort(holidays)
88
89    # Holidays falling on Saturdays and Sundays:
90    holidays =  holidays + (1-isWeekday(holidays))*24*3600
91    holidays =  holidays + (1-isWeekday(holidays))*24*3600
92
93    # Add Financial Center:
94    holidays <- timeDate(format(holidays),
95                         zone = "Toronto", FinCenter = "Toronto")
96
97    # Return Value:
98    holidays
99}
100
101
102################################################################################
103
104