一个类似于yahoo-finance的免费图书馆

时间:2018-11-04 13:54:47

标签: python api web-scraping

我发现很多允许您下载股票价格的python软件包要么不起作用,要么仅允许下载历史数据。

我的目标是下载最新数据(最好延迟15分钟),然后使用股票名称作为代码。

yahoo-finance不再适合我的需求,是否可以使用类似的库来下载这些数据?

Quandl为此产生一条错误消息:

    import quandl
    quandl.ApiConfig.api_key = 'myKey'


    data = quandl.get_table('WIKI/PRICES', ticker = ['AAPL'], 
                    qopts = { 'columns': ['ticker', 'date', 'adj_close'] }, 
                    date = { 'gte': '2015-12-31', 'lte': '2016-12-31' }, 
                    paginate=True)
    data.head()

输出:

    OptionError: "No such keys(s): 'display.large_repr'"

1 个答案:

答案 0 :(得分:1)

您可能会发现Quandl满足您的需求。

来自Quandl文档:

While free data is suitable for experimentation and exploration, we strongly recommend using premium data for professional applications.

在OP中运行代码

import quandl

# Unchanged from OP
quandl.ApiConfig.api_key = 'myKey'

data = quandl.get_table('WIKI/PRICES', ticker = ['AAPL'],
    qopts = { 'columns': ['ticker', 'date', 'adj_close'] },
    date = { 'gte': '2015-12-31', 'lte': '2016-12-31' },
    paginate=True)
data.head()
print(data)

结果-无法复制

ticker       date   adj_close
None                              
0      AAPL 2016-12-30  114.389454
1      AAPL 2016-12-29  115.288214
2      AAPL 2016-12-28  115.317843
3      AAPL 2016-12-27  115.811668
.      .... ..........  ..........
[253 rows x 3 columns]
相关问题