Search code examples
rquantmod

R quantmod: how to get >10 years of data?


I'm trying to get >10 years of data, but I haven't been able to locate how to do this using getSymbols() or chartSeries().

https://www.quantmod.com/documentation/getSymbols.html https://www.quantmod.com/documentation/chartSeries.html

Or does Yahoo only have data since 2007-01-03?

library(quantmod)
getSymbols("AAPL")
chartSeries(AAPL, type="line", subset="last 15 years")

Warning message:
In last.xts(c(13.702, 13.346, 13.619, 13.65, 13.727, 15.045, 15.234,  :
  requested length is greater than original

chartSeries(AAPL, type="line", subset="last 11 years") # this works

enter image description here


Solution

  • You need to set from to a value other than the default of 2007-01-01.

    library(quantmod)
    getSymbols("AAPL", from = "1990-01-01")
    chartSeries(AAPL, type="line", subset="last 15 years")
    

    enter image description here