R/recommendation_trends.R

Defines functions recommendation_trends

Documented in recommendation_trends

#' @title Stock recommendation trends
#' @description Trend recommendations for stocks
#'  
#' @param symbol Stock ticker
#' 
#' @importFrom purrr set_names
#' @importFrom dplyr mutate select everything
#' @importFrom lubridate ymd
#' 
#' @return
#' @export
#' 
#' @examples
#' recommendation_trends('NVDA')
recommendation_trends <- function(symbol, ...){
  
  url <- finnhub_endpoint('recommendation_trends')
  
  df <- retry_get(url,
                  query = list(token = finnhub_key(),
                               symbol = symbol)) 
  df %>% 
    dplyr::mutate(period = lubridate::ymd(period, tz = finnhub_timezone)) %>%
    dplyr::select(symbol, period, dplyr::everything()) %>% 
    purrr::set_names(c('symbol', 'period', 'buy', 'hold', 'sell', 'strong_buy',
                       'strong_sell'))
}
threadingdata/finnhubr documentation built on Aug. 10, 2020, 12:48 a.m.