fix(api,codec): 修复 BUG-1 分时采样走错命令 + BUG-2 财务文件名纠正
BUG-1: A股 get_minutes(sampling=True) 原走 MacChartSamplingCmd(0x254D) 这是 EX 协议命令,7709 主机无响应(3×8s 超时≈24s)。 修复:A股采样由 MacTickChartCmd(0x122D) 分时数据派生, EX 市场(hk)仍走 0x254D。4 个 A股 场景均<0.1s 返回 240 点。 BUG-2: tdxfin/gpcw.txt 索引声明 gpcwYYYYMMDD.zip, 但服务器实际只有 tdxfin/gpcwYYYYMMDD.dat(未压缩,~13MB), .zip 请求返回 0-1 字节空壳。 修复:_fetch_financial_dat() 自动候选回退 tdxfin/*.zip → tdxfin/*.dat → 原始文件名,加 looks_like_gpcw_dat 校验。 实测 gpcw20260630.zip→5568 条,gpcw20260331.zip→5547 条。 新增 codec/financial.py: looks_like_gpcw_dat, extract_gpcw_dat(含 zip/未压缩双通道)。 同步更新 README/API_REFERENCE/docs/cli/cookbook/CHANGELOG 共 6 处文档。 tests: +18(总 182),ruff 无新增 findings,MkDocs strict 通过。
This commit is contained in:
1 parent
b78d0fabf5
commit
8951ec2678
10 files changed
+391
-39
No files matched your search
+14
-1
@@ -118,7 +118,20 @@ async def finance_snapshot(symbols):
|
||||
print(fin.symbol, fin)
|
||||
```
|
||||
|
||||
历史专业财报(`gpcw*.zip`,含多报告期)走文件接口:
|
||||
历史专业财报(`gpcw*`,含多报告期)走文件接口。
|
||||
|
||||
!!! warning "索引里的文件名与服务器实际不一致"
|
||||
`tdxfin/gpcw.txt` 索引里写的是 `gpcwYYYYMMDD.zip`,但服务器实际只提供**未压缩的**
|
||||
`tdxfin/gpcwYYYYMMDD.dat` —— 这些差异已由 `get_financial_records_parsed()` 内部处理,
|
||||
直接把索引里的 `filename` 传进去即可。
|
||||
|
||||
另外索引里**含有尚未生成的占位条目**(`filesize` 只有百来字节),取它们会得到空列表。
|
||||
想拿最新一期可用数据,先按体积过滤:
|
||||
|
||||
```python
|
||||
usable = [fi for fi in infos if fi.filesize > 500_000] # 排除占位条目
|
||||
records = await td.get_financial_records_parsed(usable[0].filename)
|
||||
```
|
||||
|
||||
```python
|
||||
async def history_financials(code: str):
|
||||
|
||||
Reference in new issue
Block a user