fix(client): 历史资金流当日行全零 + 主力净额列缺失(issue #52)

三个根因(全部实测核实):
1. Category 22 直连接口为虚构协议——52 台已知服务器中 46 台可达的
   全部仅回 2 字节空包,从未成功过;移除死代码与臆造解析格式。
2. 历史逐笔接口当日数据要收盘清算后才有,日 K 盘中已含当日 bar,
   故 start=0 的最新一行恒为全 0——当日 bar 改走当日实时逐笔接口。
3. main_net_inflow 此前仅为 dataclass property,asdict 静默丢弃,
   返回 DataFrame 无主力净额列——新增 _fund_flow_df_with_net 物化
   (history 紧随 date 列、当日快照放首列)。

sync + async 双客户端同步修改;更新示例与三份文档;重写/新增回归
测试(当日实时逐笔路径、主力净额列断言)。
This commit is contained in:
GitHub
2026-08-26 15:00:53 +08:00
parent 7c9e19de93
commit 574ffdd2a4
8 changed files with 158 additions and 227 deletions
+13 -11
View File
@@ -2,18 +2,20 @@
使用 TdxClient 标准协议客户端,调用 get_history_fund_flow() 获取个股历史每日资金流向。
返回 HistoricalFundFlow DataFrame,每行代表一个交易日的资金流向数据。
优先走 Category 22 直连接口;若服务器返回空,自动回退为日K线+逐笔重算。
实现为"日K线取日期 + 逐笔成交重算"(通达信标准服务器无资金流专用指令,
Category 22 实测全部服务器仅回空包,见 Issue #52)。
DataFrame 列说明:
date str 交易日期(datetime
super_in float 超大单流入(元)
super_out float 超大单流(元)
large_in float 大单流(元)
large_out float 大单流(元)
medium_in float 单流(元)
medium_out float 中单流(元)
small_in float 单流(元)
small_out float 小单流(元)
date str 交易日期(datetime
main_net_inflow float 主力净流入 = (超大单+大单)流入 - 流出(元)
super_in float 超大单流(元)
super_out float 大单流(元)
large_in float 大单流(元)
large_out float 单流(元)
medium_in float 中单流(元)
medium_out float 单流(元)
small_in float 小单流(元)
small_out float 小单流出(元)
资金级别划分(按单笔成交金额):
超大单: > 100 万元
@@ -24,7 +26,7 @@ DataFrame 列说明:
数据特点:
- start 为偏移量,0=最近交易日,count 为请求数量
- 金额单位为元
- 部分服务器不支持 Category 22,此时自动回退到逐笔重算模式(较慢
- 当日行情:盘中走当日实时逐笔接口(收盘清算后历史逐笔接口才有当日数据
"""
from easy_tdx import Market, TdxClient