fix(ex): ex tick --date 接受 YYYYMMDD 整数,修复 AttributeError - #56
Merged
Conversation
Owner
|
感谢 @Harveyliu007 的优质贡献 🎉 这个 PR 已合并并随 v1.20.12 发布。几点特别值得肯定:
维护者侧已实测验证:ruff / mypy strict 通过, |
handsomejustin
pushed a commit
that referenced
this pull request
Aug 28, 2026
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.
CLI 侧传入
YYYYMMDD整数,而MacExClient.goods_tick_chart()只接受datetime.date对象。cmd_ex.py中该调用长期带# type: ignore[arg-type],类型系统也没拦住。根因
cli/cmd_ex.py的ex tick把--date(int,YYYYMMDD)原样传给goods_tick_chart(query_date=...)MacExClient/AsyncMacExClient的goods_tick_chart、goods_transaction(共 4 个方法)签名是query_date: date | None,内部直接query_date.year编码 YYYYMMDD,int 必然抛 AttributeErrorMacClient.get_tick_chart()早已支持 int(内部转换),ex 侧漏了同类处理修复
与 A 股
MacClient的 YYYYMMDD 整数语义对齐:ex/mac_client.py新增_coerce_query_date():int(YYYYMMDD)/ date / None 统一归一为 dateMacExClient/AsyncMacExClient的goods_tick_chart、goods_transaction签名改为query_date: int | date | None,内部经_coerce_query_date转换(含港股 ex 协议路由分支)cli/cmd_ex.py移除掩盖问题的# type: ignore[arg-type],ex tick --help补充--date用法示例验证
tests/unit/test_ex_tick_chart_date.py9 个回归测试:归一化纯函数(int/date/None/前导零)、同步/异步客户端三种输入、美股(74)与港股(31)路由、CLI 端到端(mock 连接层,离线)easy-tdx ex tick US_STOCK TSLA --date 20260827→ 正常返回 390 个分时点(21:30 开盘 → 03:59 收盘)改动文件
src/easy_tdx/ex/mac_client.py_coerce_query_date;4 个方法支持 int 日期src/easy_tdx/cli/cmd_ex.pytests/unit/test_ex_tick_chart_date.py备注
ex tick的--days选项当前仍未接线(扩展市场单日分时协议无多日查询),本次未改动,可另开 issue 跟进。