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

孤街醉人 提交于 2019-12-25 15:39:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!