R/filings.R

Defines functions filings

Documented in filings

#' @title Company Filings
#' @description Filings by the company
#'  
#' @param symbol Ticker symbol
#' @param from Begin date
#' @param to End date 
#' 
#' @importFrom purrr set_names
#' @importFrom dplyr mutate_at vars
#' @importFrom lubridate today ymd_hms
#' 
#' @return
#' @export
#' 
#' @examples
#' filings('NVDA')
filings <- function(symbol, 
                    from = lubridate::today(tz = finnhub_timezone) - 3650, 
                    to = lubridate::today(tz = finnhub_timezone), ...){
  
  url <- finnhub_endpoint('filings')
  
  df <- retry_get(url,
                  query = list(token = finnhub_key(),
                               symbol = symbol,
                               from = from, 
                               to = to)) 
  df %>% 
    dplyr::mutate_at(vars(filedDate, acceptedDate), 
                     ~ lubridate::ymd_hms(.x, tz = finnhub_timezone)) %>% 
    purrr::set_names(c('access_number', 'symbol' ,'cik', 'form', 'filed_date', 
                       'accepted_date', 'report_url', 'filing_url'))
}
threadingdata/finnhubr documentation built on Aug. 10, 2020, 12:48 a.m.