rquantmod

download S&P 500 data with Google as a data source, instead of Yahoo


Not sure if yahoo finances are no longer working, but I have been using google for stock data lately because yahoo public data are unavailable. However, for S&P 500 I used to use the symbol ^GSPC that used to work with yahoo, but doesn't work with google. I tried the following:

library(quantmod)
getSymbols('GSPC',src="google")
getSymbols('^GSPC',src="google")

Which generates an error message.

Is there a different symbol for google finances that represents S&P 500?


Solution

  • Yahoo Finance is working perfectly fine. For downloading GSPC you can use this:

    SPX <- getSymbols("^GSPC",auto.assign = FALSE, from = "1980-01-01")
    

    For Google as the source, you can use the example code below for the stock Johnson & Johnson

    JNJ <- getSymbols("JNJ",auto.assign = FALSE, from = "1980-01-01",src="google")
    

    For the indices though, Google does not seem to be working at the moment. For S&P 500, I see the following ticker in Google Finance:

    INDEXSP:.INX