熊猫雅虎金融实时数据 - python

是否可以从Yahoo Finance获得熊猫实时股票数据?

对于历史数据,我将执行以下操作:

import pandas.io.data as web
aapl = web.get_data_yahoo('AAPL')

有没有办法获得最新的aapl价格?

python大神给出的解决方案

编辑:

Yahoo has ended their free finance API,因此此答案不再适用。以下是我在2019年之前的答案。

档案:

有很多可用的库。熊猫没有明确地这样做。

最简单的说,我建议您只使用一个网络库来download yahoo data。我喜欢使用请求,但是您也可以使用urllib。获取响应后,可以将其强制转换为数据框。

import requests
requests.get("http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&e=.csv&f=nsl1op").text

nsl1op格式的var来自文档:

I will use here the tags of name(n), symbol(s), the latest value(l1), open(o) and the close value of the last trading day(p)

您的响应数据应类似于

u'"Apple Inc.","AAPL",114.63,113.50,115.07\r\n'

您可以使用csv库拆分字符串,然后从那里将其放入数据框