R/ipo_calendar.R

Defines functions ipo_calendar

Documented in ipo_calendar

#' @title IPO Calendar
#' @description Initial public offering calendar
#'  
#' @param from Begin date
#' @param to End date
#' 
#' @importFrom purrr set_names
#' @importFrom dplyr mutate
#' @importFrom lubridate today ymd
#' 
#' @return
#' @export
#' 
#' @examples
#' ipo_calendar()
#' ipo_calendar(from = '2019-01-01', to = lubridate::today())
#' ipo_calendar()
ipo_calendar <- function(from = lubridate::today(tz = finnhub_timezone) - 365,
                         to = lubridate::today(tz = finnhub_timezone), 
                         ...){
  
  url <- finnhub_endpoint('ipo_calendar')
  
  df <- retry_get(url,
                  query = list(token = finnhub_key(),
                               from = from, 
                               to = to)) 
  df %>% 
    .[['ipoCalendar']] %>%
    dplyr::mutate(date = lubridate::ymd(date, tz = finnhub_timezone)) %>%
    purrr::set_names(c('date', 'exchange', 'name', 'num_of_shares', 'price', 'status',
                       'symbol', 'total_share_value'))
}
threadingdata/finnhubr documentation built on Aug. 10, 2020, 12:48 a.m.