2017-05-19 36 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天)

相關問題