Title: | R Bindings to the Calendaring Functionality of 'QuantLib' |
---|---|
Description: | 'QuantLib' bindings are provided for R using 'Rcpp' via an evolved version of the initial header-only 'Quantuccia' project offering an subset of 'QuantLib' (now maintained separately just for the calendaring subset). See the included file 'AUTHORS' for a full list of contributors to 'QuantLib' (and hence also 'Quantuccia'). |
Authors: | Dirk Eddelbuettel [aut, cre] , QuantLib Authors [aut] |
Maintainer: | Dirk Eddelbuettel <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.13 |
Built: | 2024-10-16 12:37:16 UTC |
Source: | CRAN |
'QuantLib' bindings are provided for R using 'Rcpp' via an evolved version of the initial header-only 'Quantuccia' project offering an subset of 'QuantLib' (now maintained separately just for the calendaring subset). See the included file 'AUTHORS' for a full list of contributors to 'QuantLib' (and hence also 'Quantuccia').
The DESCRIPTION file:
Package: | qlcal |
Type: | Package |
Title: | R Bindings to the Calendaring Functionality of 'QuantLib' |
Version: | 0.0.13 |
Date: | 2024-10-15 |
Authors@R: | c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0001-6419-907X")), person("QuantLib Authors", role = "aut")) |
Description: | 'QuantLib' bindings are provided for R using 'Rcpp' via an evolved version of the initial header-only 'Quantuccia' project offering an subset of 'QuantLib' (now maintained separately just for the calendaring subset). See the included file 'AUTHORS' for a full list of contributors to 'QuantLib' (and hence also 'Quantuccia'). |
URL: | https://github.com/qlcal/qlcal-r, https://dirk.eddelbuettel.com/code/qlcal-r.html |
BugReports: | https://github.com/qlcal/qlcal-r/issues |
License: | GPL (>= 2) |
Imports: | Rcpp |
LinkingTo: | Rcpp, BH |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | yes |
Encoding: | UTF-8 |
Packaged: | 2024-10-15 17:25:12 UTC; edd |
Author: | Dirk Eddelbuettel [aut, cre] (<https://orcid.org/0000-0001-6419-907X>), QuantLib Authors [aut] |
Maintainer: | Dirk Eddelbuettel <[email protected]> |
Repository: | CRAN |
Date/Publication: | 2024-10-15 20:00:02 UTC |
Index of help topics:
adjust_cpp Compute adjusted dates advanceDate Advance a date advanceUnits_cpp Compute adjusted dates businessDaysBetween Compute number of business dates between calendar dates calendars The 'calendars' vector contains all calendar identifiers. getEndOfMonth Compute end-of-month getHolidays Compute holidays or business days getName Get calendar name, or id isBusinessDay Test for business days isEndOfMonth Test for end-of-month isHoliday Test for holidays isWeekend Test for weekends qlcal-package R Bindings to the Calendaring Functionality of 'QuantLib' setCalendar Set a calendar
Dirk Eddelbuettel <[email protected]>
Dirk Eddelbuettel [aut, cre] (<https://orcid.org/0000-0001-6419-907X>), QuantLib Authors [aut]
Adjust a vector of dates following a business-day convention
adjust_cpp(dates, bdc = 0L) adjust(dates, bdc = c("Following", "ModifiedFollowing", "Preceding", "ModifiedPreceding", "Unadjusted", "HalfMonthModifiedFollowing", "Nearest"))
adjust_cpp(dates, bdc = 0L) adjust(dates, bdc = c("Following", "ModifiedFollowing", "Preceding", "ModifiedPreceding", "Unadjusted", "HalfMonthModifiedFollowing", "Nearest"))
dates |
A Date vector with dates |
bdc |
A character variable describing one of several supported values, the C++ version implements expects a corresponding integer value |
This function takes a vector of dates and returns another vector of dates of the same length returning at each position the adjusted date according to the selected business-day convention. Currently supported values for the business day convention are (starting from zero): ‘Following’, ‘ModifiedFollowing’, ‘Preceding’, ‘ModifiedPreceding’, ‘Unadjusted’, ‘HalfModifiedFollowing’ and ‘Nearest’.
A Date vector with dates adjust according to business-day convention
adjust(Sys.Date()+0:6)
adjust(Sys.Date()+0:6)
Advance a date to the next business day plus an optional shift
advanceDate(rd, days = 0L, unit = "Days", bdc = "Following", eom = FALSE)
advanceDate(rd, days = 0L, unit = "Days", bdc = "Following", eom = FALSE)
rd |
A Date object describing the date to be advanced to the next business day. |
days |
An optional integer offset applied to the date |
unit |
An optional character value denoting a time unit, default value is “Day”, and supported values are “Days”, “Weeks”, “Months”, “Years”, “Hours”, “Seconds”, “Minutes”, “Milliseconds”, “Microseconds”. |
bdc |
An optional integer defining a business day convention, default is “Following”, and supported values are “Following”, “ModifiedFollowing”, “Preceding”, “ModifiedPreceding”, “Unadjusted”, “HalfMonthModifiedFollowing” and “Nearest”. |
eom |
An optional boolean toggle whether end-of-month is to be respected |
This function takes a given date and advances it to the next business day under the current (global) calendar setting. If an optional offset value is given it is applied as well.
The advanced date is returned
The advanceUnits
functions offers the same functionality from R.
advanceDate(Sys.Date(), 2) # today to the next biz day, plus 2 days
advanceDate(Sys.Date(), 2) # today to the next biz day, plus 2 days
Advance a vector of dates by a given number of time units
advanceUnits_cpp(dates, n, unit, bdc, emr) advanceUnits(dates, n, unit = c("Days", "Weeks", "Months", "Years", "Hours", "Minutes", "Seconds", "Milliseconds", "Microseconds"), bdc = c("Following", "ModifiedFollowing", "Preceding", "ModifiedPreceding", "Unadjusted", "HalfMonthModifiedFollowing", "Nearest"), emr = FALSE)
advanceUnits_cpp(dates, n, unit, bdc, emr) advanceUnits(dates, n, unit = c("Days", "Weeks", "Months", "Years", "Hours", "Minutes", "Seconds", "Milliseconds", "Microseconds"), bdc = c("Following", "ModifiedFollowing", "Preceding", "ModifiedPreceding", "Unadjusted", "HalfMonthModifiedFollowing", "Nearest"), emr = FALSE)
dates |
A Date vector with dates |
n |
An integer variable with the number of units to advance |
unit |
A character variable describing one of several supported values; the C++ version implements expects a corresponding integer value |
bdc |
A character variable describing one of several supported values, the C++ version implements expects a corresponding integer value |
emr |
A boolean variable select end-of-month, default is ‘FALSE’ |
This function takes a vector of dates and returns another vector of dates of the same length returning at each position the date advanced by the given number of steps in the selected time unit, also respecting a business day convention and and of month boolean switch. Currently supported values for the time unit are ‘Days’, ‘Weeks’, ‘Months’ ‘Years’, ‘Hours’, ‘Seconds’, ‘Milliseconds’ and ‘Microseconds’; all are specified as integers. Note that intra-daily units are not currently supported for advancing ‘Date’ objects. Currently supported values for the business day convention are (starting from zero): ‘Following’, ‘ModifiedFollowing’, ‘Preceding’, ‘ModifiedPreceding’, ‘Unadjusted’, ‘HalfModifiedFollowing’ and ‘Nearest’.
A Date vector with dates advanced according to the selected inputs
advanceUnits(Sys.Date()+0:6, 5, "Days", "Following")
advanceUnits(Sys.Date()+0:6, 5, "Days", "Following")
Compute the number of business days between dates
businessDaysBetween(from, to, includeFirst = TRUE, includeLast = FALSE)
businessDaysBetween(from, to, includeFirst = TRUE, includeLast = FALSE)
from |
A Date vector with interval start dates |
to |
A Date vector with interval end dates |
includeFirst |
A boolean indicating if the start date is included, default is ‘TRUE’ |
includeLast |
A boolean indicating if the end date is included, default is ‘FALSE’ |
This function takes two vectors of start and end dates and returns another vector of the number of business days between each corresponding date pair according to the active calendar.
A numeric vector with the number of business dates between the corresponding date pair
businessDaysBetween(Sys.Date() + 0:6, Sys.Date() + 3 + 0:6)
businessDaysBetween(Sys.Date() + 0:6, Sys.Date() + 3 + 0:6)
calendars
vector contains all calendar identifiers.The calendars
vector contains all calendar identifiers.
head(calendars, 10)
head(calendars, 10)
Compute a vector of dates with end-of-month
getEndOfMonth(dates)
getEndOfMonth(dates)
dates |
A Date vector with dates |
This function takes a vector of dates and returns another vector of dates of the same length returning at each position whether the corresponding end-of-month date in the currently active (global) calendar.
A Date vector with dates which are end-of-month
getEndOfMonth(Sys.Date()+0:6)
getEndOfMonth(Sys.Date()+0:6)
Compute the number of holidays (or business days) between two dates
getHolidays(from, to, includeWeekends = FALSE) getBusinessDays(from, to)
getHolidays(from, to, includeWeekends = FALSE) getBusinessDays(from, to)
from |
A Date object with the start date |
to |
A Date object with the end date |
includeWeekends |
A boolean indicating if weekends should be included, default is ‘FALSE’ |
This function takes a start and end date and returns a vector of holidays (or business days) between them according to the active calendar.
A Date vector with holidays or business days between the given dates
getHolidays(Sys.Date(), Sys.Date() + 30)
getHolidays(Sys.Date(), Sys.Date() + 30)
Get calendar name or id
getName() getId()
getName() getId()
This function returns the corresponding (full) name (as in the underlying implementationclass) or identification string (used to select it) of the current calendar.
A string with the calendar name
getName()
getName()
Test a vector of dates for business day
isBusinessDay(dates)
isBusinessDay(dates)
dates |
A Date vector with dates to be examined |
This function takes a vector of dates and returns a logical vector of the same length indicating at each position whether the corresponding date is a business day in the currently active (global) calendar.
A logical vector indicating which dates are business days
isBusinessDay(Sys.Date()+0:6)
isBusinessDay(Sys.Date()+0:6)
Test a vector of dates for end-of-month
isEndOfMonth(dates)
isEndOfMonth(dates)
dates |
A Date vector with dates to be examined |
This function takes a vector of dates and returns a logical vector of the same length indicating at each position whether the corresponding date is at the end of a month in the currently active (global) calendar.
A logical vector indicating which dates are end-of-month
isEndOfMonth(Sys.Date()+0:6)
isEndOfMonth(Sys.Date()+0:6)
Test a vector of dates for holiday
isHoliday(dates)
isHoliday(dates)
dates |
A Date vector with dates to be examined |
This function takes a vector of dates and returns a logical vector of the same length indicating at each position whether the corresponding date is a holiday in the currently active (global) calendar.
A logical vector indicating which dates are holidays
isHoliday(Sys.Date()+0:6)
isHoliday(Sys.Date()+0:6)
Test a vector of dates for weekends
isWeekend(dates)
isWeekend(dates)
dates |
A Date vector with dates to be examined |
This function takes a vector of dates and returns a logical vector of the same length indicating at each position whether the corresponding date is a weekend in the currently active (global) calendar.
A logical vector indicating which dates are weekends
isWeekend(Sys.Date()+0:6)
isWeekend(Sys.Date()+0:6)
Set a calendar
setCalendar(calstr)
setCalendar(calstr)
calstr |
A character variable containing the market for which a calendar is to be set |
This function sets a calendar to the given market or country convention. Note that at present only the default ‘TARGET’ and ‘UnitedStates’ are supported.
Nothing is returned but the global state is changed
setCalendar("UnitedStates")
setCalendar("UnitedStates")