efinance icon indicating copy to clipboard operation
efinance copied to clipboard

修复stock.get_quote_history无法获取数据或数据异常

Open rootphantomer opened this issue 1 year ago • 2 comments

修复 https://github.com/Micro-sheep/efinance/issues/130 这个 issue

原因:

当 低于 klt 低于 101 的时候,如 60,30 分钟线,触发的是以下 get 请求 http://35.push2his.eastmoney.com/api/qt/stock/kline/get?secid=1.600900&fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5%2Cf6&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cf58%2Cf59%2Cf60%2Cf61&klt=30&fqt=1&end=20500101&lmt=100

根据 url 分析,东方财富要求有个 lmt 参数(limit),同时 beg 和 end 参数不可自选,end 只能取默认最大值 20500101,通过改变 lmt 可以更改近几日的分钟线。目前 lmt 默认是 100

测试 30 分钟线

df = ef.stock.get_quote_history("600900", beg="20200101", end="20230101", klt=30, fqt=1,lmt=100)

可返回结果: image

新增:

ef.stock.get_quote_history 可以传入 lmt 值来控制返回的数量

rootphantomer avatar Jul 04 '23 10:07 rootphantomer