fix(mootdx): 规避 0.11.7 BESTIP.HQ 空串导致的 ValueError#7
Open
ericheroster wants to merge 1 commit into
Open
Conversation
Quotes.factory(market='std') 裸调用在 0.11.7 下抛 ValueError: not enough values to unpack (expected 2, got 0)。根因是 config.json 中 BESTIP.HQ 初始值是空字符串 (非缺失键),quotes.py:151 的 dict.get(key, default) 取不到 default,self.server = '' 拆包失败。bestip=True 自动测速也无法修复 (测速结果写不回 BESTIP.HQ)。 在 Prerequisites 增加 tdx_client() helper:含 10 个实测可达服务器列表 + TCP 握手探测 fallback,并将 SKILL.md 中 4 处 Quotes.factory(market='std') 调用替换为 tdx_client()。 已端到端验证:将 ~/.mootdx/config.json 的 BESTIP.HQ 还原为 '' 模拟全新环境后,4 个调用点 (bars / quotes / finance / F10) 均能正常返回数据。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Quotes.factory(market='std')裸调用在 mootdx 0.11.7 下会触发:按 SKILL.md V3.0 Prerequisites 安装
pip install mootdx==0.11.7后,Layer 1.1 / 6.1 / 6.2 / 7.2 共 4 处 mootdx 调用全部受影响。根因
mootdx 0.11.7 的
~/.mootdx/config.json中BESTIP.HQ初始值是空字符串"",而不是缺失键或null。quotes.py:151的逻辑:dict.get(key, default)仅在键缺失时返回default。BESTIP.HQ是存在的空串,所以self.server = "",下一行ip, port = self.server拆包失败。另外两个补充发现:
bestip=True自动测速也无法修复 —— 测速跑完后写进BESTIP.HQ的是不在 SERVER.HQ 列表里的 IP(如218.6.170.47),而且不通;改动
仅修改
SKILL.md:mootdx 客户端(必读,规避 0.11.7 已知 bug)章节,包含:_probe()TCP 握手探测函数tdx_client(market='std')helper:顺序探测 fallback,全不通则RuntimeErrorclient = Quotes.factory(market='std')调用替换为client = tdx_client():不动 README、CHANGELOG。
验证
将本地
~/.mootdx/config.json的BESTIP.HQ还原为""模拟全新安装环境,然后跑 SKILL.md 中的 helper:client.bars('119.97.185.59', 7709)client.quotesclient.financeclient.F10备选方案讨论
也考虑过其它修法:
Quotes.factory(market='std', server=('119.97.185.59', 7709))。优点最简单,缺点服务器挂了要 4 处手改。选了
tdx_client()helper 方案 —— 单点维护(升级 mootdx 后 helper 内部就只剩"探测 fallback"价值,可保留为容灾),调用方零认知负担。不影响
socket是标准库)_TDX_SERVERS是从仓库~/.mootdx/config.json的内置SERVER.HQ子集中挑出来的实测可达项,无新数据源