Analysis and Presenting Stock Time Series Data with quantmod

chengjiun
2014-07-27

quantmod

library(quantmod)

Download Stock Price Time Series Data

  • Pick a stock, and download the data from yahoo finance or google finance.
data <- getSymbols("SPY", src = "yahoo", from = "2014-01-01", to = "2014-07-01", 
    auto.assign = FALSE)
head(data, 3)
           SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2014-01-02    184.0    184.1   182.5     182.9  119636900        181.2
2014-01-03    183.2    183.6   182.6     182.9   81390600        181.2
2014-01-06    183.5    183.6   182.1     182.4  108028200        180.7

Chart

  • Show the daily price with some technical indicator:
chartSeries(data, theme = chartTheme("white"), name = "SPY", type = "candlestick")

plot of chunk unnamed-chunk-3

Demo

library(shiny)
#runApp(display.mode='showcase')