从何处以及如何获得股权历史数据(至少涵盖2008年)? [英] Where and how to get the equity historical data (at least covers 2008)?

查看:76
本文介绍了从何处以及如何获得股权历史数据(至少涵盖2008年)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下代码从Google财经获取历史数据.但是最古老的是从2016-09-20开始.这对于回测来说太短了.我需要涵盖2008年的历史数据.

I can use the following code to get historical data from Google Finance. But the oldest is from 2016-09-20. This is too short for back testing. I need historical data which covers the year of 2008.

import pandas_datareader.data as web

start = datetime.datetime(2002, 1, 1)
end = datetime.datetime(2017, 1, 27)

aapl = DataReader("AAPL", "google", start, end)
print(len(aapl))
print(aapl.head())

输出如下:

             Open   High    Low  Close    Volume
Date                                            
2016-09-20  35.02  35.06  33.91  34.44  21192908
2016-09-21  34.93  37.27  34.47  37.01  37582384
2016-09-22  38.22  38.52  37.73  38.47  22289829
2016-09-23  38.24  38.58  37.90  38.12  18705969
2016-09-26  36.69  36.94  35.63  35.97  23382130

推荐答案

使用fix-yahoo-finance,然后使用yahoo而不是Google作为您的来源.看来Google最近已经锁定了很多数据.

Use fix-yahoo-finance and then use yahoo rather than Google as your source. It looks like Google has been locking down a lot of its data lately.

首先,您需要点安装 fix-yahoo-finance .

First you'll need to pip-install fix-yahoo-finance.

然后:

from pandas_datareader import data
import fix_yahoo_finance

aapl = data.get_data_yahoo('AAPL', start='2000-01-01')

print(aapl.head())
               Open     High      Low    Close  Adj Close     Volume
Date                                                                
2000-01-03  3.74554  4.01786  3.63170  3.99777    3.59662  133949200
2000-01-04  3.86607  3.95089  3.61384  3.66071    3.29338  128094400
2000-01-05  3.70536  3.94866  3.67857  3.71429    3.34158  194580400
2000-01-06  3.79018  3.82143  3.39286  3.39286    3.05240  191993200
2000-01-07  3.44643  3.60714  3.41071  3.55357    3.19699  115183600

这篇关于从何处以及如何获得股权历史数据(至少涵盖2008年)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆