Skip to contents

Tests if a date is a business day or not.

Usage

isBizday(x, holidays = holidayNYSE(), wday = 1:5)
isHoliday(x, holidays = holidayNYSE(), wday = 1:5)

Arguments

x

an object of class "timeDate".

holidays

holiday dates from a holiday calendar. An object of class "timeDate".

wday

Specify which days should be considered as weekdays. By default from Mondays to Fridays.

Details

Returns a logical vector of the same length as x indicating if a date is a business day, or a holiday, respectively.

Value

a logical vector of the same length as x

Examples

## Dates in April, currentYear:
   currentYear = getRmetricsOptions("currentYear")
   tS = timeSequence(
      from = paste(currentYear, "-03-01", sep = ""),
      to = paste(currentYear, "-04-30", sep = ""))
   tS
#> GMT
#>  [1] [2023-03-01] [2023-03-02] [2023-03-03] [2023-03-04] [2023-03-05]
#>  [6] [2023-03-06] [2023-03-07] [2023-03-08] [2023-03-09] [2023-03-10]
#> [11] [2023-03-11] [2023-03-12] [2023-03-13] [2023-03-14] [2023-03-15]
#> [16] [2023-03-16] [2023-03-17] [2023-03-18] [2023-03-19] [2023-03-20]
#> [21] [2023-03-21] [2023-03-22] [2023-03-23] [2023-03-24] [2023-03-25]
#> [26] [2023-03-26] [2023-03-27] [2023-03-28] [2023-03-29] [2023-03-30]
#> [31] [2023-03-31] [2023-04-01] [2023-04-02] [2023-04-03] [2023-04-04]
#> [36] [2023-04-05] [2023-04-06] [2023-04-07] [2023-04-08] [2023-04-09]
#> [41] [2023-04-10] [2023-04-11] [2023-04-12] [2023-04-13] [2023-04-14]
#> [46] [2023-04-15] [2023-04-16] [2023-04-17] [2023-04-18] [2023-04-19]
#> [51] [2023-04-20] [2023-04-21] [2023-04-22] [2023-04-23] [2023-04-24]
#> [56] [2023-04-25] [2023-04-26] [2023-04-27] [2023-04-28] [2023-04-29]
#> [61] [2023-04-30]

## Subset Business Days at NYSE:
   holidayNYSE()
#> NewYork
#>  [1] [2023-01-02] [2023-01-16] [2023-02-20] [2023-04-07] [2023-05-29]
#>  [6] [2023-06-19] [2023-07-04] [2023-09-04] [2023-11-23] [2023-12-25]
   isBizday(tS, holidayNYSE())
#> 2023-03-01 2023-03-02 2023-03-03 2023-03-04 2023-03-05 2023-03-06 2023-03-07 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-03-08 2023-03-09 2023-03-10 2023-03-11 2023-03-12 2023-03-13 2023-03-14 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-03-15 2023-03-16 2023-03-17 2023-03-18 2023-03-19 2023-03-20 2023-03-21 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-03-22 2023-03-23 2023-03-24 2023-03-25 2023-03-26 2023-03-27 2023-03-28 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-03-29 2023-03-30 2023-03-31 2023-04-01 2023-04-02 2023-04-03 2023-04-04 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-04-05 2023-04-06 2023-04-07 2023-04-08 2023-04-09 2023-04-10 2023-04-11 
#>       TRUE       TRUE      FALSE      FALSE      FALSE       TRUE       TRUE 
#> 2023-04-12 2023-04-13 2023-04-14 2023-04-15 2023-04-16 2023-04-17 2023-04-18 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-04-19 2023-04-20 2023-04-21 2023-04-22 2023-04-23 2023-04-24 2023-04-25 
#>       TRUE       TRUE       TRUE      FALSE      FALSE       TRUE       TRUE 
#> 2023-04-26 2023-04-27 2023-04-28 2023-04-29 2023-04-30 
#>       TRUE       TRUE       TRUE      FALSE      FALSE 
   tS[isBizday(tS, holidayNYSE())]
#> GMT
#>  [1] [2023-03-01] [2023-03-02] [2023-03-03] [2023-03-06] [2023-03-07]
#>  [6] [2023-03-08] [2023-03-09] [2023-03-10] [2023-03-13] [2023-03-14]
#> [11] [2023-03-15] [2023-03-16] [2023-03-17] [2023-03-20] [2023-03-21]
#> [16] [2023-03-22] [2023-03-23] [2023-03-24] [2023-03-27] [2023-03-28]
#> [21] [2023-03-29] [2023-03-30] [2023-03-31] [2023-04-03] [2023-04-04]
#> [26] [2023-04-05] [2023-04-06] [2023-04-10] [2023-04-11] [2023-04-12]
#> [31] [2023-04-13] [2023-04-14] [2023-04-17] [2023-04-18] [2023-04-19]
#> [36] [2023-04-20] [2023-04-21] [2023-04-24] [2023-04-25] [2023-04-26]
#> [41] [2023-04-27] [2023-04-28]