Title: | Business Days Calculations and Utilities |
---|---|
Description: | Business days calculations based on a list of holidays and nonworking weekdays. Quite useful for fixed income and derivatives pricing. |
Authors: | Wilson Freitas [aut, cre] |
Maintainer: | Wilson Freitas <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.17 |
Built: | 2025-02-07 06:28:10 UTC |
Source: | https://github.com/wilsonfreitas/r-bizdays |
In many countries the standard approach to price derivatives and fixed income
instruments involves the use of business days. In Brazil, for example, the
great majority of financial instruments are priced on business days counting
rules. Given that the use of business days is somehow vital to handle many
tasks. That's the reason why bizdays
came up, to make these tasks
easier.
Excel's NETWORKDAYS is fairly at hand and once you have a list of
holidays it is quite easy to put your data into a spreadsheet and make
things happen.
bizdays
brings that ease to R.
Although R's users have similar feature in packages like RQuantLib
and
timeDate
it doesn't come for free. Users have to do some stackoverflow
in order to get this task accomplished. bizdays
is a tiny package
dramatically focused on that simple task: support calculations involving
business days for a given list of holidays.
bizdays
was designed to work with all common date types and ISO
formatted character strings and all methods have support for vectorized
operations and handle the recycle rule.
Wilson Freitas
Useful links:
Rolls the given date to the next or previous business day, unless it is a business day.
adjust.next(dates, cal) following(dates, cal) adjust.none(dates, cal) modified.following(dates, cal) adjust.previous(dates, cal) preceding(dates, cal) modified.preceding(dates, cal)
adjust.next(dates, cal) following(dates, cal) adjust.none(dates, cal) modified.following(dates, cal) adjust.previous(dates, cal) preceding(dates, cal) modified.preceding(dates, cal)
dates |
dates to be adjusted |
cal |
an instance of |
adjust.next
and following
return the next business day if the
given date
is not a business day.
adjust.previous
and preceding
are similar, but return the
previous
business day.
modified.following
rolls the given date to the next business day,
unless
it happens in the next month, in this case it returns the previous business
day.
modified.preceding
is similar to modified.following
, but rolls
the given
date to the previous business day.
Date
objects adjusted accordingly.
The argument dates
accepts Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
adjust.next("2013-01-01", "Brazil/ANBIMA") following("2013-01-01", "Brazil/ANBIMA") modified.following("2016-01-31", "Brazil/ANBIMA") adjust.previous("2013-01-01", "Brazil/ANBIMA") preceding("2013-01-01", "Brazil/ANBIMA") modified.preceding("2016-01-01", "Brazil/ANBIMA")
adjust.next("2013-01-01", "Brazil/ANBIMA") following("2013-01-01", "Brazil/ANBIMA") modified.following("2016-01-31", "Brazil/ANBIMA") adjust.previous("2013-01-01", "Brazil/ANBIMA") preceding("2013-01-01", "Brazil/ANBIMA") modified.preceding("2016-01-01", "Brazil/ANBIMA")
Returns the amount of business days between 2 dates taking into account the
provided Calendar
(or bizdays.options$get("default.calendar")
).
bizdays(from, to, cal)
bizdays(from, to, cal)
from |
the initial dates |
to |
the final dates |
cal |
the calendar's name |
integer
objects representing the amount of business days.
The arguments from
and to
accept Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
These arguments handle the recycle rule so vectors of dates can be provided and once those vectors differs in length the recycle rule is applied.
from
and to
are adjusted when nonworking dates are
provided. Since bizdays
function returns the amount of business days
between 2 dates, it must start and end in business days.
The default behavior, that is defined in Calendar
's instantiation with
adjust.from
and adjust.to
, reproduces the Excel's NETWORKDAYS.
A common and useful setting is adjust.to=adjust.next
which moves
expiring maturities to the next business day, once it is not.
bizdays("2013-01-02", "2013-01-31", "Brazil/ANBIMA") # Once you have a default calendar set, cal does not need to be provided bizdays.options$set(default.calendar = "Brazil/ANBIMA") bizdays("2013-01-02", "2013-01-31") dates <- bizseq("2013-01-01", "2013-01-10") bizdays(dates, "2014-01-31")
bizdays("2013-01-02", "2013-01-31", "Brazil/ANBIMA") # Once you have a default calendar set, cal does not need to be provided bizdays.options$set(default.calendar = "Brazil/ANBIMA") bizdays("2013-01-02", "2013-01-31") dates <- bizseq("2013-01-01", "2013-01-10") bizdays(dates, "2014-01-31")
bizdays.options
defines option parameters used internally in
bizdays
.
bizdays.options
bizdays.options
A list
object with methods get
and set
attached to.
Parameters are stored in bizdays.options
using get
and
set
bizdays.options$set(option.key=value) bizdays.options$get("option.key")
bizdays
supports the option default.calendar
.
It defines the default calendar to be used with the
functions: bizdays
, bizdayse
, adjust.next
,
adjust.previous
, is.bizday
, bizseq
, offset
.
create.calendar(name = "actual") bizdays.options$set(default.calendar = "actual") bizdays("2013-07-12", "2013-07-22")
create.calendar(name = "actual") bizdays.options$set(default.calendar = "actual") bizdays("2013-07-12", "2013-07-22")
bizdayse
stands for business days equivalent, it returns the amount
of business days equivalent to a given number of current days.
bizdayse(dates, curd, cal)
bizdayse(dates, curd, cal)
dates |
the reference dates |
curd |
the amount of current days |
cal |
the calendar's name |
Let us suppose I have a reference date dates
and I offset that date
by curd
current days. bizdayse
returns the business days
between the reference date and the new date offset by curd
current
days.
This is equivalent to
refdate <- Sys.Date() curd <- 10 newdate <- refdate + 10 # offset refdate by 10 days # this is equals to bizdayse(refdate, 10) bizdays(refdate, newdate)
An integer
representing an amount of business days.
The argument dates
accepts Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
These arguments handle the recycle rule so a vector of dates and a vector of numbers can be provided and once those vectors differs in length the recycle rule is applied.
bizdayse("2013-01-02", 3, "Brazil/ANBIMA")
bizdayse("2013-01-02", 3, "Brazil/ANBIMA")
Returns the number of business days between dates in a given vector of dates.
bizdiff(dates, cal)
bizdiff(dates, cal)
dates |
a vector containing the dates to be differenced |
cal |
the calendar's name |
A 'numeric' vector of length 'n-1' (where 'n' is the input vector length), containing the business days computed between pairs of dates.
The arguments from
and to
accept Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
dates <- c("2017-05-10", "2017-05-12", "2017-05-17") bizdiff(dates, "Brazil/ANBIMA")
dates <- c("2017-05-10", "2017-05-12", "2017-05-17") bizdiff(dates, "Brazil/ANBIMA")
Returns a sequence of dates with business days only.
bizseq(from, to, cal)
bizseq(from, to, cal)
from |
the initial date |
to |
the final date (must be greater than |
cal |
the calendar's name |
A vector of Date
objects that are business days according to the
provided Calendar
.
The arguments from
and to
accept Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
bizseq("2013-01-02", "2013-01-31", "Brazil/ANBIMA")
bizseq("2013-01-02", "2013-01-31", "Brazil/ANBIMA")
Returns calendar's list of holidays and weekdays
holidays(cal) ## Default S3 method: holidays(cal) ## S3 method for class 'Calendar' holidays(cal) ## S3 method for class 'character' holidays(cal) ## Default S3 method: weekdays(x, ...) ## S3 method for class 'Calendar' weekdays(x, ...) ## S3 method for class 'character' weekdays(x, ...)
holidays(cal) ## Default S3 method: holidays(cal) ## S3 method for class 'Calendar' holidays(cal) ## S3 method for class 'character' holidays(cal) ## Default S3 method: weekdays(x, ...) ## S3 method for class 'Calendar' weekdays(x, ...) ## S3 method for class 'character' weekdays(x, ...)
cal |
character with calendar name or the calendar object |
x |
character with calendar name or the calendar object |
... |
unused argument (this exists to keep compliance with
|
holidays("actual") weekdays("actual") # empty calls return the default calendar attributes holidays() weekdays()
holidays("actual") weekdays("actual") # empty calls return the default calendar attributes holidays() weekdays()
The calendars can be specified in JSON files and these functions helps with importing and exporting calendars to text files.
save_calendar(cal, con) load_calendar(con)
save_calendar(cal, con) load_calendar(con)
cal |
the calendar's name |
con |
a connection object or a character string. |
save_calendar
exports a calendar to a JSON file and
load_calendar
imports.
In load_calenadar
, the con
argument can be a connection object
or a character string specifying either the file or the JSON text.
Here's an example of a calendar's specification.
{ "name": "Brazil/ANBIMA", "weekdays": ["saturday", "sunday"], "holidays": ["2001-01-01", "2001-02-26", "2001-02-27", "2001-04-13"], "adjust.from": "following", "adjust.to": "preceding" "financial": true, }
con <- tempfile(fileext = ".json") save_calendar("actual", con) load_calendar(con)
con <- tempfile(fileext = ".json") save_calendar("actual", con) load_calendar(con)
Every calendar created with create.calendar
is stored in the
calendar register.
The idea behind this register is allowing calendars to be accessed
by its names.
calendars() remove_calendars(cals) has_calendars(cals)
calendars() remove_calendars(cals) has_calendars(cals)
cals |
character vector of calendars names |
calendars
returns the object which represents the calendars register.
Since the register inherits from environment
, the calendars are
retrieved with the [[
operator.
But the register object has its own print
generic which helps listing
all registered calendars.
remove_calendars
remove calendars from the register.
# ACTUAL calendar cal <- create.calendar("Actual") cal <- calendars()[["Actual"]] remove_calendars("Actual") # lists registered calendars calendars() has_calendars(c("actual", "weekends"))
# ACTUAL calendar cal <- create.calendar("Actual") cal <- calendars()[["Actual"]] remove_calendars("Actual") # lists registered calendars calendars() has_calendars(c("actual", "weekends"))
create.calendar
creates calendars and stores them in the calendar
register.
create.calendar( name, holidays = integer(0), weekdays = NULL, start.date = NULL, end.date = NULL, adjust.from = adjust.none, adjust.to = adjust.none, financial = TRUE )
create.calendar( name, holidays = integer(0), weekdays = NULL, start.date = NULL, end.date = NULL, adjust.from = adjust.none, adjust.to = adjust.none, financial = TRUE )
name |
calendar's name. This is used to retrieve calendars from register. |
holidays |
a vector of Dates which contains the holidays |
weekdays |
a character vector which defines the weekdays to be used as
non-working days (defaults to |
start.date |
the date which the calendar starts |
end.date |
the date which the calendar ends |
adjust.from |
is a function to be used with the |
adjust.to |
is a function to be used with the |
financial |
is a logical argument that defaults to TRUE.
This argument defines the calendar as a financial or a non
financial calendar.
Financial calendars don't consider the ending business day
when counting working days in |
The arguments start.date
and end.date
can be set but once
they aren't and holidays
is set, start.date
is defined to min(holidays)
and
end.date
to max(holidays)
.
If holidays isn't set start.date
is set to '1970-01-01'
and
end.date
to '2071-01-01'
.
weekdays
is controversial but it is only a sequence of nonworking
weekdays.
In the great majority of situations it refers to the weekend but it is also
possible defining
it differently.
weekdays
accepts a character
sequence with lower case
weekdays (
sunday
, monday
, tuesday
, wednesday
,
thursday
, friday
, saturday
).
This argument defaults to NULL
because the default intended behavior
for
create.calendar
returns an actual calendar, so calling
create.calendar(name="xxx")
returns a actual calendar named xxx.
(for more calendars see
Day Count Convention)
To define the weekend as the nonworking weekdays one could simply
use weekdays=c("saturday", "sunday")
.
The arguments adjust.from
and adjust.to
are used to adjust
bizdays
' arguments
from
and to
, respectively.
These arguments need to be adjusted when nonworking days are provided.
The default behavior, setting adjust.from=adjust.previous
and
adjust.to=adjust.next
,
works like Excel's function NETWORKDAYS, since that is fairly used by a
great number of practitioners.
Every named calendar is stored in a register so that it can be retrieved by
its name (in calendars
).
bizdays' methods also accept the calendar's name on their cal
argument.
Given that, naming calendars is strongly recommended.
# ANBIMA's calendar (from Brazil) holidays <- as.Date(c( "2015-01-01", "2015-02-16", "2015-02-17", "2015-04-03", "2015-04-21", "2015-05-01", "2015-06-04", "2015-09-07", "2015-10-12", "2015-11-02", "2015-11-15", "2015-12-25", "2016-01-01", "2016-02-08", "2016-02-09", "2016-03-25", "2016-04-21", "2016-05-01", "2016-05-26", "2016-09-07", "2016-10-12", "2016-11-02", "2016-11-15", "2016-12-25" )) cal <- create.calendar("ANBIMA", holidays = holidays, weekdays = c("saturday", "sunday") ) # ACTUAL calendar cal <- create.calendar("Actual") # named calendars can be accessed by its name create.calendar(name = "Actual") bizdays("2016-01-01", "2016-03-14", "Actual")
# ANBIMA's calendar (from Brazil) holidays <- as.Date(c( "2015-01-01", "2015-02-16", "2015-02-17", "2015-04-03", "2015-04-21", "2015-05-01", "2015-06-04", "2015-09-07", "2015-10-12", "2015-11-02", "2015-11-15", "2015-12-25", "2016-01-01", "2016-02-08", "2016-02-09", "2016-03-25", "2016-04-21", "2016-05-01", "2016-05-26", "2016-09-07", "2016-10-12", "2016-11-02", "2016-11-15", "2016-12-25" )) cal <- create.calendar("ANBIMA", holidays = holidays, weekdays = c("saturday", "sunday") ) # ACTUAL calendar cal <- create.calendar("Actual") # named calendars can be accessed by its name create.calendar(name = "Actual") bizdays("2016-01-01", "2016-03-14", "Actual")
Calculates the number of business days for some specific periof of a year
or a month.
getbizdays
returns the number of business days according to a
reference than can be another date, a month or an year.
getbizdays(ref, cal = bizdays.options$get("default.calendar"))
getbizdays(ref, cal = bizdays.options$get("default.calendar"))
ref |
a reference which represents a month or year, where the date has to be found. |
cal |
the calendar's name
|
# for years getbizdays(2022:2024, "Brazil/ANBIMA") # for months getbizdays("2022-12", "Brazil/ANBIMA")
# for years getbizdays(2022:2024, "Brazil/ANBIMA") # for months getbizdays("2022-12", "Brazil/ANBIMA")
Imagine you have one date and want the first or last day of this date's
month.
For example, you have the date 2018-02-01 and want the last day of its month.
You have to check whether or not its year is a leap year, and this sounds a
tough task.
getdate
helps with returning specific dates according to a reference
than can be another date, a month or an year.
getdate(expr, ref, cal = bizdays.options$get("default.calendar"))
getdate(expr, ref, cal = bizdays.options$get("default.calendar"))
expr |
a character string specifying the date to be returned (see Details) |
ref |
a reference which represents a month or year, where the date has to be found. |
cal |
the calendar's name |
expr
represents the day has to be returned, here it follows a few
examples:
"second day"
"10th bizday"
"3rd wed"
"last bizday"
"first fri"
expr
is a character string with two terms: "<position> <day>"
positions: first
or 1st
,
second
or 2nd
,
third
or 3rd
, last
and XXth
(examples
6th
or 11th
)
days: day
, bizday
, or weekdays (sun
, mon
,
tue
, wed
, thu
, fri
, sat
)
getdate
returns dates according to a reference that can be a month or
an year. This reference can be passed as a character vector representing
months or years, or as a numeric vector representing years.
The ISO format must be used to represent years or months with character
vectors.
a vector of dates according to a reference (month or year)
getdate("10th wed", 2018, "Brazil/ANBIMA") getdate("last bizday", 2010:2018, "Brazil/ANBIMA") dts <- seq(as.Date("2018-01-01"), as.Date("2018-12-01"), "month") getdate("first bizday", format(dts, "%Y-%m"), "Brazil/ANBIMA") getdate("last bizday", Sys.Date(), "Brazil/ANBIMA") getdate("next bizday", Sys.Date(), "Brazil/ANBIMA") getdate("2nd wed", Sys.Date()) getdate("next wed", Sys.Date()) getdate("last wed", Sys.Date()) getdate("next mon", Sys.Date()) getdate("last mon", Sys.Date())
getdate("10th wed", 2018, "Brazil/ANBIMA") getdate("last bizday", 2010:2018, "Brazil/ANBIMA") dts <- seq(as.Date("2018-01-01"), as.Date("2018-12-01"), "month") getdate("first bizday", format(dts, "%Y-%m"), "Brazil/ANBIMA") getdate("last bizday", Sys.Date(), "Brazil/ANBIMA") getdate("next bizday", Sys.Date(), "Brazil/ANBIMA") getdate("2nd wed", Sys.Date()) getdate("next wed", Sys.Date()) getdate("last wed", Sys.Date()) getdate("next mon", Sys.Date()) getdate("last mon", Sys.Date())
Returns TRUE
if the given date is a business day and FALSE
otherwise.
is.bizday(dates, cal)
is.bizday(dates, cal)
dates |
dates to be checked |
cal |
the calendar's name |
logical
objects informing that given dates are or are not business
days.
The argument dates
accepts Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
is.bizday("2013-01-02", "Brazil/ANBIMA") # Once you have a default calendar set, cal does not need to be provided bizdays.options$set(default.calendar = "Brazil/ANBIMA") dates <- seq(as.Date("2013-01-01"), as.Date("2013-01-05"), by = "day") is.bizday(dates)
is.bizday("2013-01-02", "Brazil/ANBIMA") # Once you have a default calendar set, cal does not need to be provided bizdays.options$set(default.calendar = "Brazil/ANBIMA") dates <- seq(as.Date("2013-01-01"), as.Date("2013-01-05"), by = "day") is.bizday(dates)
bizdays comes with builtins calendars:
load_builtin_calendars()
load_builtin_calendars()
- actual - weekends - Brazil/ANBIMA - Brazil/B3
This function creates and registers these calendars. Once the calendars are loaded they can be used directly by their names.
This function is called in package '.onAttach', so it is not necessary to call it directly. It is for internal use, package development or in situations where the user wants to call bizdays functions without attach the package.
Has no return
bizdays::load_builtin_calendars() bizdays::calendars() bizdays::is.bizday("2020-01-01", "Brazil/ANBIMA")
bizdays::load_builtin_calendars() bizdays::calendars() bizdays::is.bizday("2020-01-01", "Brazil/ANBIMA")
dates
by n
business daysReturns the given dates
offset by the given amount of n
business days.
offset(dates, n, cal) add.bizdays(dates, n, cal)
offset(dates, n, cal) add.bizdays(dates, n, cal)
dates |
dates to be offset |
n |
the amount of business days to offset |
cal |
the calendar's name |
The argument n
accepts a sequence of integers and if its length
differs from dates
' length, the recycle rule is applied to fulfill the
gap.
Date
objects offset by the amount of days defined.
The argument dates
accepts Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
These arguments handle the recycle rule so a vector of dates and a vector of numbers can be provided and once those vectors differs in length the recycle rule is applied.
offset("2013-01-02", 5, "Brazil/ANBIMA") # Once you have a default calendar set, cal does not need to be provided bizdays.options$set(default.calendar = "Brazil/ANBIMA") dates <- seq(as.Date("2013-01-01"), as.Date("2013-01-05"), by = "day") is.bizday(dates) offset(dates, 1)
offset("2013-01-02", 5, "Brazil/ANBIMA") # Once you have a default calendar set, cal does not need to be provided bizdays.options$set(default.calendar = "Brazil/ANBIMA") dates <- seq(as.Date("2013-01-01"), as.Date("2013-01-05"), by = "day") is.bizday(dates) offset(dates, 1)
The packages RQuantLib and timeDate (Rmetrics) have functions to compute business days between 2 dates according to a predefined calendar. bizdays creates calendars based on these functions.
load_quantlib_calendars(ql_calendars = NULL, from, to, financial = TRUE) load_rmetrics_calendars(year, financial = TRUE)
load_quantlib_calendars(ql_calendars = NULL, from, to, financial = TRUE) load_rmetrics_calendars(year, financial = TRUE)
ql_calendars |
(QuantLib only) A character vector with the names of QuantLib's calendars. This parameter defaults to NULL, which loads all calendars. |
from |
(QuantLib only) the start date |
to |
(QuantLib only) the end date |
financial |
is a logical argument that defaults to TRUE. |
year |
(timeDate Rmetrics only) a vector with years to create the calendars. |
To load QuantLib's calendars use load_quantlib_calendars
defining
which
calendar has to be loaded by its name and the range of dates the calendar
has to handle.
All QuantLib calendars have the QuantLib
prefix.
To load Rmetrics' calendars use load_rmetrics_calendars
defining the
years the calendar has to handle.
All Rmetrics calendars have the Rmetrics
prefix.
This argument defines the calendar as a financial or a non financial
calendar.
Financial calendars don't consider the ending business day when counting
working days in bizdays
.
In QuantLib, Financial calendars are those that includeLast
is set
to FALSE
.
QuantLib Calendars:
QuantLib/TARGET
QuantLib/Argentina
QuantLib/Australia
QuantLib/Brazil
QuantLib/Canada
QuantLib/Canada/Settlement
QuantLib/Canada/TSX
QuantLib/China
QuantLib/CzechRepublic
QuantLib/Denmark
QuantLib/Finland
QuantLib/Germany
QuantLib/Germany/FrankfurtStockExchange
QuantLib/Germany/Settlement
QuantLib/Germany/Xetra
QuantLib/Germany/Eurex
QuantLib/HongKong
QuantLib/Hungary
QuantLib/Iceland
QuantLib/India
QuantLib/Indonesia
QuantLib/Italy
QuantLib/Italy/Settlement
QuantLib/Italy/Exchange
QuantLib/Japan
QuantLib/Mexico
QuantLib/NewZealand
QuantLib/Norway
QuantLib/Poland
QuantLib/Russia
QuantLib/SaudiArabia
QuantLib/Singapore
QuantLib/Slovakia
QuantLib/SouthAfrica
QuantLib/SouthKorea
QuantLib/SouthKorea/KRX
QuantLib/Sweden
QuantLib/Switzerland
QuantLib/Taiwan
QuantLib/Turkey
QuantLib/Ukraine
QuantLib/UnitedKingdom
QuantLib/UnitedKingdom/Settlement
QuantLib/UnitedKingdom/Exchange
QuantLib/UnitedKingdom/Metals
QuantLib/UnitedStates
QuantLib/UnitedStates/Settlement
QuantLib/UnitedStates/NYSE
QuantLib/UnitedStates/GovernmentBond
QuantLib/UnitedStates/NERC
Rmetrics Calendars:
Calendar Rmetrics/LONDON
Calendar Rmetrics/NERC
Calendar Rmetrics/NYSE
Calendar Rmetrics/TSX
Calendar Rmetrics/ZURICH
if (require("RQuantLib")) { # loading Argentina calendar load_quantlib_calendars("Argentina", from = "2016-01-01", to = "2016-12-31" ) bizdays("2016-01-01", "2016-03-14", "QuantLib/Argentina") # loading 2 calendars load_quantlib_calendars(c("UnitedStates/NYSE", "UnitedKingdom/Settlement"), from = "2016-01-01", to = "2016-12-31" ) bizdays("2016-01-01", "2016-03-14", "QuantLib/UnitedStates/NYSE") # loading all QuantLib's 50 calendars load_quantlib_calendars(from = "2016-01-01", to = "2016-12-31") bizdays("2016-01-01", "2016-03-14", "QuantLib/Brazil") } if (require("timeDate")) { # loading all Rmetrics calendar load_rmetrics_calendars(2016) bizdays("2016-01-01", "2016-03-14", "Rmetrics/NERC") bizdays("2016-01-01", "2016-03-14", "Rmetrics/NYSE") }
if (require("RQuantLib")) { # loading Argentina calendar load_quantlib_calendars("Argentina", from = "2016-01-01", to = "2016-12-31" ) bizdays("2016-01-01", "2016-03-14", "QuantLib/Argentina") # loading 2 calendars load_quantlib_calendars(c("UnitedStates/NYSE", "UnitedKingdom/Settlement"), from = "2016-01-01", to = "2016-12-31" ) bizdays("2016-01-01", "2016-03-14", "QuantLib/UnitedStates/NYSE") # loading all QuantLib's 50 calendars load_quantlib_calendars(from = "2016-01-01", to = "2016-12-31") bizdays("2016-01-01", "2016-03-14", "QuantLib/Brazil") } if (require("timeDate")) { # loading all Rmetrics calendar load_rmetrics_calendars(2016) bizdays("2016-01-01", "2016-03-14", "Rmetrics/NERC") bizdays("2016-01-01", "2016-03-14", "Rmetrics/NYSE") }