Skip to content

Instantly share code, notes, and snippets.

@ianfmc
Created June 26, 2017 04:12
Show Gist options
  • Save ianfmc/84444adbfd6d27269f56cdf741a8330b to your computer and use it in GitHub Desktop.
Save ianfmc/84444adbfd6d27269f56cdf741a8330b to your computer and use it in GitHub Desktop.
library(plotly)
library(quantmod)
getSymbols("AAPL",src='yahoo')
# basic example of ohlc charts
df <- data.frame(Date=index(AAPL),coredata(AAPL))
df <- tail(df, 30)
p <- df %>%
plot_ly(x = ~Date, type="candlestick",
open = ~AAPL.Open, close = ~AAPL.Close,
high = ~AAPL.High, low = ~AAPL.Low) %>%
layout(title = "Basic Candlestick Chart")
# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link = plotly_POST(p, filename="finance/candlestick-basic")
chart_link
Copy to clipboard!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment