#' @title News Sentiment
#' @description Sentiment ratings for a company
#'
#' @param symbol Ticker symbol
#'
#' @importFrom tibble as_tibble
#' @importFrom purrr set_names
#' @importFrom lubridate now
#' @importFrom dplyr mutate select everything
#'
#' @return
#' @export
#'
#' @examples
#' news_sentiment('NVDA')
news_sentiment <- function(symbol, ...){
url <- finnhub_endpoint('news_sentiment')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol))
df %>%
data.frame %>%
as_tibble %>%
dplyr::mutate(symbol = symbol) %>%
purrr::set_names(c('buzz_last_week', 'buzz_current', 'buzz_weekly_avg',
'company_news_score', 'sector_bullish_avg', 'sector_news_score',
'bearish_sentiment', 'sentiment_bullish', 'symbol')) %>%
dplyr::select(symbol, dplyr::everything()) %>%
dplyr::mutate(query_date = lubridate::now(tz = finnhub_timezone))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.