Comments (13)
原因大概是因为json的decoder有问题,
debug到decorder文件的这部分
def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):
"""Decode a JSON document from ``s`` (a ``str`` or ``unicode`` 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 in ``s`` where the JSON document begins. This can be used to decode a JSON document from a string that may have extraneous data at the end. """ if idx < 0: # Ensure that raw_decode bails on negative indexes, the regex # would otherwise mask this behavior. #98 raise JSONDecodeError('Expecting value', s, idx) if _PY3 and not isinstance(s, str): raise TypeError("Input string must be text, not bytes") # strip UTF-8 bom if len(s) > idx: ord0 = ord(s[idx]) if ord0 == 0xfeff: idx += 1 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': idx += 3 return self.scan_once(s, idx=_w(s, idx).end())
报错是
JSONDecodeError: Expecting value
把核心调用代码发一下,我本地试试看,还有提供一下 python 版本、操作系统以及 efinance 的版本号。
from efinance.
原因大概是因为json的decoder有问题,
debug到decorder文件的这部分
def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):"""Decode a JSON document from ``s`` (a ``str`` or ``unicode`` 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 in ``s`` where the JSON document begins. This can be used to decode a JSON document from a string that may have extraneous data at the end. """ if idx < 0: # Ensure that raw_decode bails on negative indexes, the regex # would otherwise mask this behavior. #98 raise JSONDecodeError('Expecting value', s, idx) if _PY3 and not isinstance(s, str): raise TypeError("Input string must be text, not bytes") # strip UTF-8 bom if len(s) > idx: ord0 = ord(s[idx]) if ord0 == 0xfeff: idx += 1 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': idx += 3 return self.scan_once(s, idx=_w(s, idx).end())
报错是
JSONDecodeError: Expecting value把核心调用代码发一下,我本地试试看,还有提供一下 python 版本、操作系统以及 efinance 的版本号。
stock_codes= '招商积余' # 001914也一样
df = ef.stock.get_quote_history(stock_codes=code,klt=1)
这步调用就直接报错了,奇怪的是它是间歇性的,一段时间内怎么运行都bug。过了一会运行就可能没错。
py3.8 ef0.3.8 mac spyder和pycharm都有这个问题。
麻烦大佬debug了哈
from efinance.
我在 Windows 系统的 python 3.7 版本下跑了 100 次,均是正常的,在 docker 里面的 miniconda 管理的 python 3.7 版本也是正常。测试代码如下
import efinance as ef
# 对同一只股票测试 100 次
ef.stock.get_quote_history(['招商积余']*100)
from efinance.
你试一下等几分钟再跑一次,这个偶尔会通,似乎和时间段有关,原因应该是获取请求但是没有返回数据。
from efinance.
你试一下等几分钟再跑一次,这个偶尔会通,似乎和时间段有关,原因应该是获取请求但是没有返回数据。
klt=1 的话,如果是交易日,得在非早上 9点到9点半之间运行。因为这个时间段东方财富会重置分钟线数据。
from efinance.
现在也不能用,凡是交易时段就不用能是吧,,
from efinance.
刚刚也试了,没啥问题的
如果你的还是不行,可以试试重新安装一遍 efinance
from efinance.
原因大概是因为json的decoder有问题,
debug到decorder文件的这部分
def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):"""Decode a JSON document from ``s`` (a ``str`` or ``unicode`` 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 in ``s`` where the JSON document begins. This can be used to decode a JSON document from a string that may have extraneous data at the end. """ if idx < 0: # Ensure that raw_decode bails on negative indexes, the regex # would otherwise mask this behavior. #98 raise JSONDecodeError('Expecting value', s, idx) if _PY3 and not isinstance(s, str): raise TypeError("Input string must be text, not bytes") # strip UTF-8 bom if len(s) > idx: ord0 = ord(s[idx]) if ord0 == 0xfeff: idx += 1 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': idx += 3 return self.scan_once(s, idx=_w(s, idx).end())
报错是
JSONDecodeError: Expecting value把核心调用代码发一下,我本地试试看,还有提供一下 python 版本、操作系统以及 efinance 的版本号。
stock_codes= '招商积余' # 001914也一样
df = ef.stock.get_quote_history(stock_codes=code,klt=1)
这步调用就直接报错了,奇怪的是它是间歇性的,一段时间内怎么运行都bug。过了一会运行就可能没错。
py3.8 ef0.3.8 mac spyder和pycharm都有这个问题。
麻烦大佬debug了哈
提供一下属于 efinance
的报错代码。原生的这些库基本上不会有问题,我得知道是 efinance
里面的哪一部分代码报错。
from efinance.
Traceback (most recent call last):
File "/Users/ttt/.spyder-py3/temp.py", line 47, in
query()
File "/Users/ttt/.spyder-py3/temp.py", line 29, in query
df = ef.stock.get_quote_history(stock_codes=code,klt=1)
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/stock/getter.py", line 235, in get_quote_history
df = get_quote_history_for_stock(
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/common/getter.py", line 190, in get_quote_history
return get_quote_history_single(codes,
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/utils/init.py", line 33, in run
values = func(*args, **kwargs)
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/efinance/common/getter.py", line 87, in get_quote_history_single
json_response = session.get(
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/requests/models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/simplejson/init.py", line 525, in loads
return _default_decoder.decode(s)
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/Users/ttt/opt/anaconda3/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value
from efinance.
那我理解就是run 这个函数没有读到值
from efinance.
那我理解就是run 这个函数没有读到值
你试一下别的股票代码,然后klt
保持默认,如果可以,那就重新安装 efinace
再试之前报错的代码,避免搜索缓存更新有问题。如果还是不行,我再远程帮你看看吧,我这边没法复现问题。
from efinance.
我知道了,你的url请求的这个域名和api返回经常是502就是报错,用浏览器和requests请求都试过了。
'http://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get'。'http://push2his.eastmoney.com/
from efinance.
我知道了,你的url请求的这个域名和api返回经常是502就是报错,用浏览器和requests请求都试过了。 'http://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get'。'http://push2his.eastmoney.com/
嗯,这估计跟网络有关吧。国内网络直连一般是正常的,至少我的没有出现过问题,无论使用的是个人电脑、服务器、手机热点的网络。你检查一下是不是用了代理。
from efinance.
Related Issues (20)
- 期货获取1分钟数据能否超过一天的 HOT 1
- 期货 15 分钟数据有错误 HOT 2
- 如何获取美股跟港股的最近交易日的交易数据 HOT 1
- 获取每日复盘信息
- 能否补充一下查询主营业务的接口
- 股票代码加密api似乎有问题
- 获取分钟k线只能获取近两个月的数据 HOT 3
- 股票数据多线程下载的过程中,出现了异常:TypeError: __new__() got an unexpected keyword argument 'security_typeNa: ' HOT 1
- 请问如何获取"季报披露时间“表格 HOT 1
- get_history_bill issue HOT 1
- get_latest_quote() 今天一直报错 JSONDecodeError HOT 1
- efinance.stock.get_quote_history("CN00Y")
- 拉数据出错 HOT 2
- 能否获取 商品期货的 指数? HOT 1
- n天期货分钟k线问题 HOT 1
- 请问大佬,哪个函数可以获取股票的上市时间?最好是多任务?
- 如何获取所有非A股(美股等)的stock code 列表 HOT 3
- 最新版(0.5.1)efinance.stock.get_top10_stock_holder_info 特别慢 HOT 1
- 出现包弃用的警告提示
- 使用 py3.10时出现notifyAll() 报错的解决方案
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efinance.