#' @title Stock price target
#' @description Get price target for a company
#'
#' @param symbol Stock ticker
#'
#' @importFrom purrr set_names
#' @importFrom dplyr bind_rows mutate select
#' @importFrom lubridate ymd_hms
#'
#' @return
#' @export
#'
#' @examples
#' price_target('NVDA')
price_target <- function(symbol, ...){
url <- finnhub_endpoint('price_target')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol))
df %>%
dplyr::bind_rows() %>%
dplyr::mutate(last_updated = lubridate::ymd_hms(lastUpdated,
tz = finnhub_timezone)) %>%
dplyr::select(symbol, last_updated, targetHigh:targetMedian) %>%
purrr::set_names(c('symbol', 'last_updated', 'target_high', 'target_low',
'target_mean', 'target_median'))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.