efinance icon indicating copy to clipboard operation
efinance copied to clipboard

get_quote_history 获取多个标的时不稳定

Open vensentzhou opened this issue 3 years ago • 9 comments

在日常使用中,使用get_quote_history获取多个标的时,(最近)出现多次获取失败,无响应的的情况,请问大佬有什么改善的方法? 截屏2022-11-12 11 45 13

vensentzhou avatar Nov 12 '22 03:11 vensentzhou

截屏2022-11-12 11 31 03

vensentzhou avatar Nov 12 '22 03:11 vensentzhou

在日常使用中,使用get_quote_history获取多个标的时,(最近)出现多次获取失败,无响应的的情况,请问大佬有什么改善的方法? 截屏2022-11-12 11 45 13

我今天试了一下,也是会遇到这个问题,有时候会卡在某一只股票上面,但是我单独获取这只股票之后,后面再和其他的放在一起获取,就不会再卡住。具体原因待我调试之后再说。

Micro-sheep avatar Nov 14 '22 02:11 Micro-sheep

我测试情况也是这样,所以现在临时采用for循环 单票取数据,期待大佬的研究成果。

vensentzhou avatar Nov 14 '22 03:11 vensentzhou

我最近也经常卡,有时获取个位数股票时,总是卡在最后几个,更别说几十只股票的情况了。

six7ths avatar Nov 26 '22 08:11 six7ths

我最近也经常卡,有时获取个位数股票时,总是卡在最后几个,更别说几十只股票的情况了。

把源代码的这一段改为下面这一段测试看看呢?我这边改了之后测试几次大量获取也没有发现卡住。 https://github.com/Micro-sheep/efinance/blob/b88696fd31911da27f62c2e365930508a2c93bac/efinance/common/getter.py#L97

改为

url = 'http://7.push2his.eastmoney.com/api/qt/stock/kline/get'

具体更新方法是

# 下载代码
git clone https://github.com/Micro-sheep/efinance
# 本地安装
cd efinance
pip install -e .

之后按我说的修改文件 efinance/common/getter.py 中的对应部分再进行测试。

Micro-sheep avatar Nov 26 '22 10:11 Micro-sheep

这个问题目前还存在,改了URL还是卡住,不知道是什么问题

tyewu avatar Dec 14 '22 06:12 tyewu

我最近也经常卡,有时获取个位数股票时,总是卡在最后几个,更别说几十只股票的情况了。

把源代码的这一段改为下面这一段测试看看呢?我这边改了之后测试几次大量获取也没有发现卡住。

https://github.com/Micro-sheep/efinance/blob/b88696fd31911da27f62c2e365930508a2c93bac/efinance/common/getter.py#L97

改为

url = 'http://7.push2his.eastmoney.com/api/qt/stock/kline/get'

具体更新方法是

# 下载代码
git clone https://github.com/Micro-sheep/efinance
# 本地安装
cd efinance
pip install -e .

之后按我说的修改文件 efinance/common/getter.py 中的对应部分再进行测试。

将多进程直接改为gevent 来进行协成请求就可以解决问题了

nrliangxy avatar Apr 10 '23 15:04 nrliangxy

我尝试替换了一下,用几天看看情况如何。

Micro-sheep avatar Apr 10 '23 16:04 Micro-sheep

我尝试替换了一下,用几天看看情况如何。

def get_quote_history_multi( codes: List[str], beg: str = '19000101', end: str = '20500101', klt: int = 101, fqt: int = 1, tries: int = 3, **kwargs, ) -> Dict[str, pd.DataFrame]: """ 获取多只股票、债券历史行情信息 """ # dfs: Dict[str, pd.DataFrame] = {} total = len(codes) pool = Pool(total) coroutine_list = [pool.spawn(get_quote_history_single, x) for x in codes] gevent.joinall(coroutine_list) df_value = [_.value for _ in coroutine_list] dfs = dict(zip(codes, df_value)) return dfs 跑跑这个,应该就可以了

nrliangxy avatar Apr 11 '23 00:04 nrliangxy