问题
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?
回答1:
Yahoo Finance is working perfectly fine. For downloading GSPC you can use this:
SPX <- getSymbols("^GSPC",auto.assign = FALSE, from = "1980-01-01")
For goole as source you can use as below, this is 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 the S&P 500, I see the following ticker in google finance:
INDEXSP:.INX
回答2:
The .INX doesn't work, but if you only care about returns statistics and such, you can use the ETF that tracks the index. It has the ticker SPY.
来源:https://stackoverflow.com/questions/43564516/download-sp-500-data-with-google-as-a-data-source-instead-of-yahoo