#' @title Revenue Estimates
#' @description Get forecast and history of revenue estimates - quarterly or annual
#'
#' @param symbol Stock ticker
#' @param freq Frequency - quarterly or annual
#'
#' @importFrom tibble as_tibble
#' @importFrom purrr set_names
#' @importFrom dplyr mutate select everything
#' @importFrom lubridate ymd
#'
#' @return
#' @export
#'
#' @examples
#' revenue_estimates('NVDA', freq = 'quarterly')
#' revenue_estimates('NVDA', freq = 'annual')
revenue_estimate <- function(symbol, freq = 'quarterly', ...){
url <- finnhub_endpoint('revenue_est')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol,
freq = freq))
df %>%
.[['data']] %>%
tibble::as_tibble() %>%
dplyr::mutate(symbol = symbol,
date = lubridate::ymd(period, tz = finnhub_timezone)) %>%
dplyr::select(symbol, date, dplyr::everything()) %>%
purrr::set_names(c('symbol', 'date', 'num_of_analysts', 'period', 'revenue_avg',
'revenue_high', 'revenue_low'))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.