SIT.date package is the collection of functions to ease extraction of date period ends.
The first function that i want to highlight is the date.ends function.
This is a user friendly wrapper to compute periods ends with optional logic to handle
holidays if holiday calendar is provided. It handles various commonly used periodicity by mapping them
into corresponding end period functions. For example, weeks, week, weekly, and w are all mapped into `date.week.ends’.
It also handles bi-weekly syntax by taking every other period end. For more precise handling you can directly
specify by and skip input parameters.
Please note the date.ends function works differently depending on the input data type.
I.e. if xts object is given, assume that xts is sourced from historical data and does not contain holidays
otherwise first filter out non business days and next apply dates periodicity function.
Let’s checkout some examples:
dates
31-Oct-2013 Thu
31-Dec-2013 Tue
28-Feb-2014 Fri
30-Apr-2014 Wed
30-Jun-2014 Mon
29-Aug-2014 Fri
31-Oct-2014 Fri
31-Dec-2014 Wed
dates
29-Nov-2013 Fri
31-Jan-2014 Fri
31-Mar-2014 Mon
30-May-2014 Fri
31-Jul-2014 Thu
30-Sep-2014 Tue
28-Nov-2014 Fri
10-Jan-2015 Sat
dates
29-Nov-2013 Fri
31-Jan-2014 Fri
31-Mar-2014 Mon
30-May-2014 Fri
31-Jul-2014 Thu
30-Sep-2014 Tue
28-Nov-2014 Fri
10-Jan-2015 Sat
We can also specify a calendar to only consider business dates:
dates
06-Mar-2015 Fri
13-Mar-2015 Fri
20-Mar-2015 Fri
27-Mar-2015 Fri
02-Apr-2015 Thu
10-Apr-2015 Fri
17-Apr-2015 Fri
24-Apr-2015 Fri
01-May-2015 Fri
dates
06-Mar-2015 Fri
13-Mar-2015 Fri
20-Mar-2015 Fri
27-Mar-2015 Fri
02-Apr-2015 Thu
10-Apr-2015 Fri
17-Apr-2015 Fri
24-Apr-2015 Fri
01-May-2015 Fri
dates
06-Mar-2015 Fri
13-Mar-2015 Fri
20-Mar-2015 Fri
27-Mar-2015 Fri
03-Apr-2015 Fri
10-Apr-2015 Fri
17-Apr-2015 Fri
24-Apr-2015 Fri
01-May-2015 Fri
You also might find handy the custom.date.bus and custom.date functions.
These functions handle custom syntax to specify date ends. The expression given to these functions must
be in the following format: