我試圖從Google財經中提取指數的歷史數據,但它不起作用。雖然我能夠輕鬆獲取個股的歷史數據。我是否在索引方面做錯了什麼?Python - 從Google財經中提取指數數據
我的股票代碼
from pandas_datareader import data
from dateutil.relativedelta import relativedelta
import datetime as dt
enddate = dt.datetime.today()
begdate = enddate + relativedelta(years=-1)
x= data.get_data_google("GOOGL",begdate,enddate)
print(x.head())
輸出
Open High Low Close Volume
Date
2016-05-24 719.85 734.20 719.64 733.03 1890195
2016-05-25 735.00 739.89 732.60 738.10 1610773
2016-05-26 736.00 741.10 733.00 736.93 1298295
2016-05-27 737.51 747.91 737.01 747.60 1738913
2016-05-31 748.76 753.48 745.57 748.85 2124248
我對指數代碼
x= data.get_data_google(".DJI",begdate,enddate)
錯誤
RemoteDataError: Unable to read URL: http://www.google.com/finance/historical
這可能是相關的,但可能不是問題本身。檢查「export csv」鏈接實際指向的端點(例如使用螢火蟲),搜尋熊貓代碼以確保它嘗試訪問同一鏈接,然後嘗試訪問DJI的可比較鏈接。這將表明大熊貓試圖檢索的東西不是從谷歌提供的。 – Scott
似乎它試圖擊中的鏈接是:http://www.google.com/finance/historical?q=INDEXDJX%3A.DJI&startdate=Oct+20%2C+2016&enddate=Oct+20%2C+2017&output=csv這在谷歌財務上不存在。 –