Creating Candlestick charts in R
library(tidyquant)
library(plotly)
Plotting S&P 500 etf (SPY) price data since March 1, 2019. We will use the below code to plot the chart using plotly.
spy_price <- tq_get('SPY',
from = '2018-03-01',
to = "2018-05-15",
get = 'stock.prices')
spy_price %>%
plot_ly(x = ~date,
type = 'candlestick',
open = ~open,
close = ~close,
high = ~high,
low = ~low) %>%
layout(title = 'SPY Price since March 2019',
xaxis = list(rangeslider = list(visible = F)))
Read other posts