#' @title Technical Indicators
#' @description Get technical indicators
#'
#' @param symbol Stock ticker
#' @param resolution 1-minute, 5-minute, 15-minute, 30-minute, 60-minute,
#' daily, weekly and monthly
#' @param indicator Selected indicator
#' @param from Begin date - default 30-days from today
#' @param to End date - current date
#'
#' @importFrom dplyr bind_cols rename mutate select everything
#'
#' @return
#' @export
#'
#' @examples
#' technical_indicators('NVDA')
#' technical_indicators('NVDA', indicator = 'SMA')
#' technical_indicators('NVDA', indicator = 'EMA')
#' technical_indicators('NVDA', indicator = 'TEMA')
#' technical_indicators('NVDA', indicator = 'RSI')
#' technical_indicators('NVDA', indicator = 'BBANDS')
#' technical_indicators('NVDA', resolution = 1, indicator = 'BBANDS')
#' technical_indicators('NVDA', resolution = 5)
#' technical_indicators('NVDA', resolution = 15)
#' technical_indicators('NVDA', resolution = 30)
#' technical_indicators('NVDA', resolution = 60)
#' technical_indicators('NVDA', resolution = 'D')
#' technical_indicators('NVDA', from = lubridate::today() - 365, resolution = 'W', indicator = 'BBANDS')
technical_indicators <- function(symbol,
indicator = 'SMA',
resolution = 'D',
from = today() - 14,
to = today(),
...){
from <- date_to_unix(from)
to <- date_to_unix(to)
url <- finnhub_endpoint('technical_indicators')
df <- retry_get(url,
query = list(token = finnhub_key(),
symbol = symbol,
indicator = indicator,
resolution = resolution,
from = from,
to = to))
df$s <- NULL
df %>%
dplyr::bind_cols() %>%
dplyr::rename(close = c,
high = h,
low = l,
open = o,
unixtime = t,
volume = v) %>%
dplyr::mutate(symbol = symbol) %>%
dplyr::select(symbol, unixtime, open, high, low, close, volume, dplyr::everything())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.