-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在stock_get_quote_history中出现bug #23
Comments
把核心调用代码发一下,我本地试试看,还有提供一下 python 版本、操作系统以及 efinance 的版本号。 |
stock_codes= '招商积余' # 001914也一样 |
我在 Windows 系统的 python 3.7 版本下跑了 100 次,均是正常的,在 docker 里面的 miniconda 管理的 python 3.7 版本也是正常。测试代码如下 import efinance as ef
# 对同一只股票测试 100 次
ef.stock.get_quote_history(['招商积余']*100) |
你试一下等几分钟再跑一次,这个偶尔会通,似乎和时间段有关,原因应该是获取请求但是没有返回数据。 |
klt=1 的话,如果是交易日,得在非早上 9点到9点半之间运行。因为这个时间段东方财富会重置分钟线数据。 |
现在也不能用,凡是交易时段就不用能是吧,, |
提供一下属于 |
Traceback (most recent call last): File "/Users/ttt/.spyder-py3/temp.py", line 47, in File "/Users/ttt/.spyder-py3/temp.py", line 29, in query File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/stock/getter.py", line 235, in get_quote_history File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/common/getter.py", line 190, in get_quote_history File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/utils/init.py", line 33, in run File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/common/getter.py", line 87, in get_quote_history_single File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/requests/models.py", line 910, in json File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/simplejson/init.py", line 525, in loads File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode JSONDecodeError: Expecting value |
那我理解就是run 这个函数没有读到值 |
你试一下别的股票代码,然后 |
我知道了,你的url请求的这个域名和api返回经常是502就是报错,用浏览器和requests请求都试过了。 |
嗯,这估计跟网络有关吧。国内网络直连一般是正常的,至少我的没有出现过问题,无论使用的是个人电脑、服务器、手机热点的网络。你检查一下是不是用了代理。 |
原因大概是因为json的decoder有问题,
debug到decorder文件的这部分
def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):
"""Decode a JSON document from
s
(astr
orunicode
beginning with a JSON document) and return a 2-tuple of the Python
representation and the index in
s
where the document ended.Optionally,
idx
can be used to specify an offset ins
wherethe JSON document begins.
报错是
JSONDecodeError: Expecting value
The text was updated successfully, but these errors were encountered: