#' @title Earnings Calendar
#' @description Get earnings calendar for a company. EPS and revenue estimate
#' vs. actual by quarter
#'
#' @param symbol Stock ticker
#' @param from Begin date
#' @param to End date
#' @param international Include international stocks; true or false
#'
#' @importFrom purrr set_names
#' @importFrom dplyr mutate select everything
#' @importFrom lubridate ymd
#'
#' @return
#' @export
#'
#' @examples
#' earnings_calendar('NVDA')
#' earnings_calendar('NVDA', from = lubridate::today() - 720)
#' earnings_calendar('NVDA', international = 'false')
earnings_calendar <- function(symbol,
from = today() - 365,
to = today(),
international = 'true', ...){
url <- finnhub_endpoint('earnings_calendar')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol,
from = from,
to = to,
international = international))
df %>%
.[['earningsCalendar']] %>%
dplyr::mutate(date = lubridate::ymd(date, tz = finnhub_timezone)) %>%
dplyr::select(symbol, date, dplyr::everything()) %>%
purrr::set_names(c('symbol', 'date', 'eps_actual', 'eps_estimate', 'hour',
'quarter', 'revenue_actual', 'revenue_estimate', 'year'))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.