【发布时间】:2017-06-26 06:14:44
【问题描述】:
我一直在 python 中使用 yahoo 财务模块。在过去的几个月里,我把这个项目搁置了,然后又重新开始了。不幸的是,雅虎财务模块背后似乎没有任何东西了!
我从pypi documents 运行示例代码并没有得到任何回报。
>>> from yahoo_finance import Share
>>> yahoo = Share('YHOO')
>>> print yahoo.get_open()
None
>>> print yahoo.get_price()
None
>>> print yahoo.get_trade_datetime()
None
虽然我能够打开 GOOG,但当我尝试访问历史数据时出现错误,并且似乎无法访问任何股票的历史数据。
None
>>> goog = Share('GOOG')
>>> goog.get_open()
'956.83'
>>> print(yahoo.get_open())
None
>>> goog.get_historical('2014-04-25', '2014-04-29')
Traceback (most recent call last):
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packag
es\yahoo_finance\__init__.py", line 120, in _request
_, results = response['query']['results'].popitem()
AttributeError: 'NoneType' object has no attribute 'popitem'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packag
es\yahoo_finance\__init__.py", line 123, in _request
raise YQLQueryError(response['error']['description'])
KeyError: 'error'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packag
es\yahoo_finance\__init__.py", line 342, in get_historical
result = self._request(query)
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packag
es\yahoo_finance\__init__.py", line 125, in _request
raise YQLResponseMalformedError()
yahoo_finance.YQLResponseMalformedError: Response malformed.
>>>
我尝试使用更新的日期范围运行,但没有运气。该模块似乎根本无法获得历史数据,而几周前它还是可靠的。有什么见解吗?
【问题讨论】:
-
我理解我几个月前写的解决方法。 gist.github.com/Krewn/0e624d35c396df63262dd42d74f2beb6我不明白为什么没人维护python模块。
标签: python yahoo-finance