R/etf_profile.R

Defines functions etf_profile

Documented in etf_profile

#' @title ETF Profile
#' @description Get exchange traded fund profile
#'   
#' @param etf ETF ticker - SPY, XLK, IYW
#' 
#' @importFrom tibble tibble
#' @importFrom dplyr bind_cols mutate
#' @importFrom lubridate now
#' 
#' @return
#' @export
#' 
#' @examples
#' etf_profile('SPY')
#' etf_profile('XLK')
#' etf_profile('IYW')
etf_profile <- function(etf, ...){
  
  url <- finnhub_endpoint('etfs_profile')
  
  df <- retry_get(url, 
                  query = list(token = finnhub_key(),
                               symbol = etf))
  df %>% 
    .[['profile']] %>% 
    dplyr::bind_cols() %>%
    tibble::tibble(etf, .) %>% 
    mutate(query_date = lubridate::now())
}  
threadingdata/finnhubr documentation built on Aug. 10, 2020, 12:48 a.m.