R/show_special_day.R

Defines functions show_special_day

Documented in show_special_day

#' @title show_special_day
#' @description Shows if a date is the first/last trading day of the week/month.
#' @param date_as_char character, a date (inputted as a string) in YYYY-MM-DD format (%Y-%m-%d), Defaults to today's date
#' @return A string indicating any of the three: EOM (end of month), SOM (start of month), EOW (end of week).
#' @export 
show_special_day <- function(date_as_char)
{
  if (missing(date_as_char)) date_as_char <- Sys.Date()
  else date_as_char <- as.Date(date_as_char)
  if (!file.exists('data/dates.rds')) make_dates()
  dates <- readRDS('data/dates.rds')
  out <- sapply(dates, function(x) date_as_char %in% x)
  out[1:3] %>% .[.] %>% names
}
causality-loop/clhelpers documentation built on Aug. 31, 2022, 3:39 a.m.