release: v0.6.0(统一对外接口重构)
按「数据类型」合并同类查询接口:一个数据类型 = 一个方法,跨市场自动选路。 - 28 个统一接口(get_universe/get_quotes/get_bars/get_indicators/get_ticks/ get_minutes/get_f10/get_file/get_boards/get_board_of/get_snapshot 等), 标的统一字符串写法(sz000001 / hk00700 / usAAPL / cffex:IFL0); 同名旧方法不再兼容 (market, code) 元组。 - 旧 51 个按通道/市场分裂的接口:33 个保留为 deprecated 别名(1.0 移除), 18 个同名升级为统一接口。公开方法共 63 个。 - 新增库层标的解析 pytdxdata.symbols;数据模型追加 symbol/name/fields 兜底字段。 - 修复:分页器连接泄漏、日期区间 K线返回 0 条(偏移方向探测)、池子全冷却死等。 - 文档/README/SKILL/llms.txt 全量同步;新增 docs/refactor-audit.md 审查报告。 - 测试 127 个用例全绿(含 tests/test_all_interfaces.py 全 63 方法回归)。
This commit is contained in:
1 parent
1bee6b0fc7
commit
3e0beb27a6
33 files changed
+2789
-1270
No files matched your search
@@ -252,7 +252,7 @@ def _new_tdxdata() -> TdxData:
|
||||
async def test_api_get_block_parsed():
|
||||
td = _new_tdxdata()
|
||||
raw = _make_block_dat([("银行", ["000001"], 1, 1)])
|
||||
with mock.patch.object(td, "get_block_info", new=mock.AsyncMock(return_value=raw)):
|
||||
with mock.patch.object(td, "get_file", new=mock.AsyncMock(return_value=raw)):
|
||||
blocks = await td.get_block_parsed("block_gn.dat")
|
||||
assert len(blocks) == 1
|
||||
assert blocks[0].category == 2 # gn -> 概念
|
||||
@@ -263,7 +263,7 @@ async def test_api_get_industry_map():
|
||||
td = _new_tdxdata()
|
||||
raw = "0|000001|A01|||S01\n".encode("gbk")
|
||||
patched = mock.AsyncMock(return_value=raw)
|
||||
with mock.patch.object(td, "get_report_file", new=patched):
|
||||
with mock.patch.object(td, "get_file", new=patched):
|
||||
result = await td.get_industry_map()
|
||||
patched.assert_awaited_once_with("tdxhy.cfg")
|
||||
assert result["000001"].sw_industry == "S01"
|
||||
@@ -274,7 +274,7 @@ async def test_api_get_financial_file_infos():
|
||||
td = _new_tdxdata()
|
||||
raw = b"gpcw20260331.zip,abc,1024\n"
|
||||
patched = mock.AsyncMock(return_value=raw)
|
||||
with mock.patch.object(td, "get_report_file", new=patched):
|
||||
with mock.patch.object(td, "get_file", new=patched):
|
||||
infos = await td.get_financial_file_infos()
|
||||
patched.assert_awaited_once_with("tdxfin/gpcw.txt")
|
||||
assert infos[0].filesize == 1024
|
||||
@@ -284,7 +284,7 @@ async def test_api_get_financial_file_infos():
|
||||
async def test_api_get_financial_records_parsed():
|
||||
td = _new_tdxdata()
|
||||
zip_bytes = _make_financial_zip(_valid_two_record_dat())
|
||||
with mock.patch.object(td, "get_report_file",
|
||||
with mock.patch.object(td, "get_file",
|
||||
new=mock.AsyncMock(return_value=zip_bytes)):
|
||||
recs = await td.get_financial_records_parsed("tdxfin/gpcw20260331.zip")
|
||||
assert len(recs) == 2
|
||||
@@ -294,7 +294,7 @@ async def test_api_get_financial_records_parsed():
|
||||
@pytest.mark.asyncio
|
||||
async def test_api_get_financial_records_parsed_empty_zip_data():
|
||||
td = _new_tdxdata()
|
||||
with mock.patch.object(td, "get_report_file",
|
||||
with mock.patch.object(td, "get_file",
|
||||
new=mock.AsyncMock(return_value=b"")):
|
||||
assert await td.get_financial_records_parsed("tdxfin/gpcw20260331.zip") == []
|
||||
|
||||
@@ -303,7 +303,7 @@ async def test_api_get_financial_records_parsed_empty_zip_data():
|
||||
async def test_api_get_financial_records_parsed_no_dat_member():
|
||||
td = _new_tdxdata()
|
||||
zip_bytes = _make_financial_zip(b"whatever", inner_name="readme.txt")
|
||||
with mock.patch.object(td, "get_report_file",
|
||||
with mock.patch.object(td, "get_file",
|
||||
new=mock.AsyncMock(return_value=zip_bytes)):
|
||||
assert await td.get_financial_records_parsed("nodate.zip") == []
|
||||
|
||||
@@ -313,7 +313,7 @@ async def test_api_get_financial_records_parsed_no_date_in_name():
|
||||
"""文件名无 8 位日期 -> 回退用 .dat 头部报告期。"""
|
||||
td = _new_tdxdata()
|
||||
zip_bytes = _make_financial_zip(_valid_two_record_dat())
|
||||
with mock.patch.object(td, "get_report_file",
|
||||
with mock.patch.object(td, "get_file",
|
||||
new=mock.AsyncMock(return_value=zip_bytes)):
|
||||
recs = await td.get_financial_records_parsed("gpcw.zip")
|
||||
assert recs[0].report_date == 20260331
|
||||
Reference in new issue
Block a user