2017-05-19 34 views
2

所以我最近下载了yahoo_finance API及其1.4.0版本。我几天前得到它,而.get_historical()工作正常。然而,现在它没有。继承人在做什么:Yahoo Finance API .get_historical()不工作python

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中是否存在错误或者我忘记了什么?

+0

是的,有一个错误https://github.com/lukaszbanasiak/yahoo-finance/issues/128,似乎API正在慢慢死亡http://www.financial-hacker.com/bye-yahoo-and-thank-你换的鱼/#更2443 – davedwards

回答

0

不幸的是,雅虎股票价格API不再适用,很多模块都基于这些API。

或者,你可以使用谷歌的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时间戳1是从第一行偏移的间隔(偏移1天)