Justin Gu
1f040afabf
feat(reconnect): 引入服务器健康分引擎 + K线空数据故障转移
...
彻底解决通达信服务器"跳来跳去"问题:
1. 新增 _health.py 健康分引擎:失败乘性降权(×0.5)、连续失败3次进
120s 冷却、成功加性恢复(+0.2)。rank_by_health 按 latency/score
(有效延迟)重排,冷却中的剔除。全健康时恒等映射,对既有测试零影响。
2. get_index_bars/get_security_bars 空数据时自动逐台换台(此前直接
返回空 DataFrame,是日志"指数K线响应在第1/800条处被截断"后用户拿
不到数据的根因)。复用泛化后的 _find_host_returning_data。
3. select_best_host_*/find_working_host_* 应用 rank_by_health 重排;
空数据验证失败/异常时调 record_failure,命中调 record_success。
4. 8 个 _execute(A股/MAC/EX/MAC-EX × sync/async)统一注入健康分记录:
成功 record_success、连接失败 record_failure。
5. security_bars 截断日志区分"首条即空(服务器无数据)"与"末尾截断"。
测试:26 个新增(15 health + 7 failover + 4 ex-client 健康分追踪),
全量 reconnect/failover/decode 回归通过,ruff/mypy 通过。
2026-07-13 15:59:28 +08:00
GitHub
d0d65d64b8
feat: v1.20.0 服务器失败自动 ping 切换(无需手动 easy-tdx ping)
...
服务器连不上或返回空数据时,自动测速切到延迟最低的可用服务器再试,
Python API / CLI / Web API 三入口全部自动生效。
核心改动:
- _reconnect.py 新增 select_best_host_sync/async(连接失败 failover)
和 find_working_host_sync/async(空数据逐台实测)
- 8 个 client 的 _execute 注入跨主机故障转移(复用 auto_reconnect 开关)
- get_market_stat 空数据时按延迟顺序逐台实测找返回数据的服务器
- 新增 _reconnect/_areconnect helper 收敛重建连接副本
- MacClient failover 用 save_best_mac_host(延续 v1.19.4 不污染 best_host)
- 顺手修复 test_commands_offline 未使用 import(main CI failure 根因)
测试:925 passed(新增 18 个 failover 测试),ruff/mypy 零新增错误。
2026-07-08 18:07:37 +08:00
GitHub
155328df8b
release: v1.16.2 — 三轮审计质量加固(B6.9→A7.9)
...
经三轮代码审计后的综合质量加固版本,覆盖协议核心层、数据正确性、
错误处理、测试真实度与可维护性。761 单测全绿(+58),ruff/mypy 全过。
主要修复:
- 离线 .day 写入原子化(fsync + _repair_tail + 读取校验,CQS 守住)
- 回测止损前视偏差(延迟下一根开盘 + 跳空保护)
- VWAP 权重索引 / bar_time fail-fast / 绩效除零保护
- 闭包绑定 / 路径穿越 / naive datetime 跨时区 / ruff UP038
重构:
- 抽 AsyncHeartbeatMixin 收敛 4 处心跳副本(12→1)
- 统一 _RETRY_DELAYS 退避序列 / scanner 失败可观测性
新增 5 个测试文件 + 公共 API 类型契约,CI 加 Windows 矩阵 +
trusted publishing 签名 + 锁文件。
详见 CHANGELOG.md
2026-07-02 03:37:37 +08:00
GitHub
615994ad72
feat(kline): 分钟级K线时间戳可选bar_time对齐Tushare (Discussion #7 )
...
通达信协议用bar开始时间打时间戳(5min线上午最后一根标11:25、下午第一根标13:00;午休11:30-13:00无bar),而Tushare/同花顺/聚宽用bar结束时间(标11:30/13:05)。新增bar_time参数让用户一键切换,避免自行+5分钟偏移。
- 全部3条K线路径覆盖:A股get_security_bars/get_index_bars、扩展行情get_instrument_bars、MAC get_stock_kline(含同步+异步、get_stock_kline_with_indicators)
- CLI kline新增--bar-time {start,end}选项;Web /bars、/bars/index新增bar_time查询参数
- bar_time=start(默认)保持完全向后兼容;bar_time=end仅对分钟级周期(1/5/15/30/60min)生效,自动按周期时长右移并处理跨小时/跨日边界
- 协议解码层零改动,偏移作为纯展示语义在client层后处理,单一工具函数_apply_bar_time_align_df/_apply_bar_time_align_bars复用于全部路径
- 新增27个单元测试(test_codec_datetime.py偏移逻辑 + test_kline_bar_time.py三路径覆盖),全量700单测通过
- bump 版本号至 1.16.0
2026-06-30 15:02:27 +08:00
GitHub and Claude Opus 4.7
4820b4a049
feat: v1.1.0 - MAC protocol, CLI tool, extended markets, unified client
...
- Add MacClient/AsyncMacClient with full MAC protocol support (quotes, kline
with adjustment, tick charts, transactions, boards, capital flow, auction,
unusual, symbol info, server info)
- Add MacExClient/AsyncMacExClient for extended markets (HK, US, futures)
- Add UnifiedTdxClient auto-routing between A-share and extended markets
- Add `easy-tdx` CLI tool with JSON default output, Agent-friendly
- Add field bitmap protocol for custom quote field selection
- Fix quote-list missing fields (default to BASIC+VOLUME preset)
- Add config.py with centralized host management and auto-discovery
- Add 50+ examples covering all APIs (01-20)
- Rewrite README with CLI-first, Agent-friendly documentation
- Bump version to 1.1.0
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-22 22:44:45 +08:00
GitHub and Claude Opus 4.7
50491f9aae
feat!: rename project from xmtdx to easy-tdx
...
- Package directory: src/xmtdx/ -> src/easy_tdx/
- Import path: from easy_tdx import ...
- pip install easy-tdx
- Add LICENSE (MIT) with upstream attribution (pytdx, xmtdx)
- Add NOTICE with detailed attribution
- Update all examples, tests, scripts, docs
- Bump version to 1.0.0
BREAKING CHANGE: import path changed from `xmtdx` to `easy_tdx`
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-21 23:21:21 +08:00