#' tcycle
#'
#' @description Whether a day for US or Canadian crude is within trade cycle
#' @param x A date class object
#' @param mkt A string of "canada" or "usdomestic"
#' @return A string of "tcycle" or "post"
#' @export
#' @author Philippe Cote
tcycle <- function(x, mkt = "canada") {
market <- flowmonth <- trade.cycle.end <- NULL
tmp <- RTL::tradeCycle %>% dplyr::filter(market == mkt)
tcycleEnd <- as.Date(tmp %>%
dplyr::filter(flowmonth == lubridate::rollback(x,roll_to_first = TRUE) + months(1)) %>%
dplyr::pull(trade.cycle.end))
return(ifelse(x <= tcycleEnd, "tcycle","post"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.