雅虎财经 API .get_historical() 不工作 python [英] Yahoo Finance API .get_historical() not working python

查看:42
本文介绍了雅虎财经 API .get_historical() 不工作 python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我最近下载了 yahoo_finance API 及其版本 1.4.0.几天前我得到了它,并且 .get_historical() 工作正常.然而现在,它没有.这是它在做什么:

So I recently downloaded the yahoo_finance API and its version 1.4.0. I got it a few days ago, and the .get_historical() was working fine. Now however, it doesn't. Heres what its doing:

import yahoo_finance as yf

apple=yf.Share('AAPL')
apple_price=apple.get_price()

print apple.get_historical('2016-02-15', '2016-04-29')

我得到的错误是:YQLResponseMalformedError:响应格式错误.API 中是否存在错误或我忘记了什么?

The error I get is:YQLResponseMalformedError: Response malformed. Is there a bug in the API or am I forgetting something?

推荐答案

不幸的是,雅虎股票价格 API 不再起作用,很多模块都基于它.

The Yahoo Stock Price API doesn't work anymore, which a lot of modules are based on, unfortunately.

或者,您可以使用 Google 的 APIhttps://www.google.com/finance/getprices?q=1101&x=TPE&i=86400&p=3d&f=d,c,h,l,o,v

Alternatively, you could use Google's API https://www.google.com/finance/getprices?q=1101&x=TPE&i=86400&p=3d&f=d,c,h,l,o,v

q=1101 is the stock quote
x=TPE is the exchange (List of Exchanges here: https://www.google.com/googlefinance/disclaimer/ )
i=86400 interval in seconds (86400 sec = 1 day)
p=3d data since how long ago
f= fields of data (d=date, c=close, h=high, l=low, o=open, v=volume)

数据看起来像这样:

EXCHANGE%3DTPE
MARKET_OPEN_MINUTE=540
MARKET_CLOSE_MINUTE=810
INTERVAL=86400
COLUMNS=DATE,CLOSE,HIGH,LOW,OPEN,VOLUME
DATA=
TIMEZONE_OFFSET=480
a1496295000,24.4,24.75,24.35,24.75,11782000
1,24.5,24.5,24.3,24.4,10747000

a1496295000 是第一行数据的 Unix 时间戳

a1496295000 is the Unix timestamp of first row of data

第二行 1 是与第一行的间隔偏移量(偏移 1 天)

the second row 1 is the interval offset from first row (offset 1 day)

这篇关于雅虎财经 API .get_historical() 不工作 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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