library(dplyr)
library(stringr)
# Works with time-based tibbles
idx <- tk_make_timeseries("2017-01-01", "2017-12-31", by = "day")
# --- BASIC USAGE ----
tk_get_holiday_signature(idx)
# ---- FILTERING WITH PATTERNS & SETS ----
# List available holidays - see patterns
tk_get_holidays_by_year(2020) %>%
filter(holiday_name %>% str_detect("US_"))
# Filter using holiday patterns
# - Get New Years, Christmas and Thanksgiving Features in US
tk_get_holiday_signature(
idx,
holiday_pattern = "(US_NewYears)|(US_Christmas)|(US_Thanks)",
locale_set = "none",
exchange_set = "none")
# ---- APPLYING FILTERS ----
# Filter with locale sets - Signals all holidays in a locale
tk_get_holiday_signature(
idx,
holiday_pattern = "$^", # Matches nothing on purpose
locale_set = "US",
exchange_set = "none")
# Filter with exchange sets - Signals Common Non-Business Days
tk_get_holiday_signature(
idx,
holiday_pattern = "$^", # Matches nothing on purpose
locale_set = "none",
exchange_set = "NYSE")
Run the code above in your browser using DataLab