Justin Gu
|
6b98715a14
|
fix(client): get_index_bars/get_security_bars 加空数据故障转移
指数/板块指数(880xxx 等)并非所有服务器都提供,延迟最低的不一定返回数据。
实测约 6/47 台可达主机对所有指数返回空 body 且不报错,from_best_host() 按纯
延迟选主会选中这种"快但空"的主机,导致 get_index_bars 返回空 DataFrame。
get_market_stat 早有 _find_host_returning_quotes 兜底,但 K 线查询缺失同类逻辑。
本提交补齐对称设计:
- 新增 _find_host_returning_bars(sync + async):照搬 _find_host_returning_quotes
模式,复用 find_working_host_sync/_async(最多试 5 台、带持久化、异常吞掉、
全失败回退原 host)
- get_security_bars / get_index_bars(sync + async 共 4 处)接入:空数据且
auto_reconnect 开启时触发逐台实测,找首台返回数据的 host
- 新增 TestIndexBarsEmptyFailover(5 个测试):覆盖空数据切 host、全候选空、
非空不触发、auto_reconnect=False 不触发、个股 K 线同链路
验证:23 个 failover 测试全绿,941 个单元测试无回归。
|
2026-07-10 19:37:31 +08:00 |
|