mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 14:34:18 +08:00
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:
@@ -329,10 +329,10 @@ c.get_block_info(filename: str) -> list[TdxBlock]
|
||||
### get_fund_flow
|
||||
|
||||
```python
|
||||
c.get_fund_flow(market: Market, code: str) -> FundFlow
|
||||
c.get_fund_flow(market: Market, code: str) -> pd.DataFrame
|
||||
```
|
||||
|
||||
获取个股当日资金流向(基于 L1 逐笔数据统计)。
|
||||
获取个股当日资金流向(基于 L1 逐笔数据统计)。返回含 `main_net_inflow`(主力净流入)列。
|
||||
|
||||
**资金分级**:
|
||||
| 级别 | 单笔成交额 |
|
||||
@@ -346,10 +346,12 @@ c.get_fund_flow(market: Market, code: str) -> FundFlow
|
||||
|
||||
```python
|
||||
c.get_history_fund_flow(market: Market, code: str,
|
||||
start: int, count: int) -> list[HistoricalFundFlow]
|
||||
start: int, count: int) -> pd.DataFrame
|
||||
```
|
||||
|
||||
获取历史日线资金流向序列。优先走直连接口,若服务器不支持则自动回退为逐笔成交重算。
|
||||
获取历史日线资金流向序列,由"日K线取日期 + 逐笔成交重算"实现(标准服务器
|
||||
无资金流专用指令,Issue #52)。当日 bar 盘中取当日实时逐笔。返回列含
|
||||
`main_net_inflow`(主力净流入,单位元)。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -260,6 +260,7 @@
|
||||
|
||||
| 字段名 | 中文 | 类型 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| `main_net_inflow` | 主力净流入 | `float` | 列:超大+大净额(Issue #52 起物化为列) |
|
||||
| `super_in` | 超大单流入 | `float` | 单笔 >100 万 |
|
||||
| `super_out` | 超大单流出 | `float` | |
|
||||
| `large_in` | 大单流入 | `float` | 20~100 万 |
|
||||
@@ -268,7 +269,6 @@
|
||||
| `medium_out` | 中单流出 | `float` | |
|
||||
| `small_in` | 小单流入 | `float` | ≤4 万 |
|
||||
| `small_out` | 小单流出 | `float` | |
|
||||
| `main_net_inflow` | 主力净流入 | `float` | 属性:超大+大 |
|
||||
| `total_net_inflow` | 全单净流入 | `float` | 属性:全部 |
|
||||
|
||||
---
|
||||
@@ -277,7 +277,7 @@
|
||||
|
||||
来源:`get_history_fund_flow()`
|
||||
|
||||
字段同 FundFlow,额外包含:
|
||||
字段同 FundFlow(`main_net_inflow` 同样物化为列,紧随 `date` 之后),额外包含:
|
||||
|
||||
| 字段名 | 中文 | 类型 |
|
||||
|--------|------|------|
|
||||
|
||||
@@ -231,12 +231,15 @@ gotdx 同样命名为 `Unknown`,pytdx 直接 `pos += 9`。
|
||||
fixture 中 87 条记录全部为 0x00(87/87)。无其他可能值样本,推测为保留/对齐字节。
|
||||
gotdx 命名为 `Unknown`,pytdx 注释 `# noused`。
|
||||
|
||||
### 4.3 fund_flow 9字节响应头部(已确认:同 xdxr_info 格式)
|
||||
### 4.3 fund_flow(Category 22)——已证伪并移除(Issue #52)
|
||||
|
||||
**位置**:`commands/fund_flow.py:45`
|
||||
**位置**:`commands/fund_flow.py`(已删除)
|
||||
|
||||
与 xdxr_info 相同的 9 字节头部格式:prefix(2) + market(1) + code(6)。
|
||||
后接 uint16 num(记录数量),然后是 36 字节/条的固定记录。
|
||||
曾有实现假设 0x052D + category=22 为"历史资金流向"指令,并按
|
||||
"9 字节头 + uint16 num + 36 字节/条"解析。**2026-08-26 实测**(Issue #52):
|
||||
全部 46 台可达标准行情服务器对该请求仅回 2 字节 body(`0000` 或 `2003`),
|
||||
即 0 条记录 / ret_count 撒谎空包,从未在任何环境返回过有效数据。
|
||||
响应格式属臆造,该命令已删除;资金流改为"日K取日期 + 逐笔成交重算"。
|
||||
|
||||
gotdx 未实现此命令。
|
||||
|
||||
@@ -374,7 +377,7 @@ xdxr_info 9字节头部(fixture 验证):
|
||||
xdxr_info 每条1字节 padding:
|
||||
- 87 条记录全部为 0x00,保留/对齐字节
|
||||
|
||||
fund_flow 9字节头部:同 xdxr_info 格式(prefix + market + code)
|
||||
fund_flow 9字节头部:~~同 xdxr_info 格式~~ 2026-08-26 证伪(见 4.3,命令已删除)
|
||||
|
||||
block 384字节头部:gotdx 命名"头信息, 忽略",所有实现跳过
|
||||
|
||||
|
||||
Reference in New Issue
Block a user