mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 20:24:19 +08:00
feat: 完善实时行情字段并增加大文件拉取功能
1. 行情增强:解析 SecurityQuote 中的 limit_up (涨停价) 和 limit_down (跌停价)。 2. 新增命令:实现 GetReportFileCmd (0x06B9),支持从服务器拉取 base_info.zip 等大文件。 3. 客户端 API:TdxClient/AsyncTdxClient 增加 get_report_file 方法,支持自动分片。 4. 验证脚本:增加 verify_limits.py 和 verify_report_file.py 实测脚本。 5. 文档更新:README.md 同步 API 变更及数据模型更新。
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""验证大文件拉取。"""
|
||||
import sys
|
||||
import pathlib
|
||||
import zipfile
|
||||
import io
|
||||
|
||||
# 添加 src 到 path
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent / "src"))
|
||||
|
||||
from xmtdx import TdxClient
|
||||
|
||||
def main():
|
||||
print("正在拉取 base_info.zip ...")
|
||||
with TdxClient.from_best_host() as c:
|
||||
data = c.get_report_file("base_info.zip")
|
||||
print(f"成功拉取 {len(data)} 字节。")
|
||||
|
||||
if not data:
|
||||
print("失败:返回数据为空。")
|
||||
return
|
||||
|
||||
# 尝试作为 zip 打开验证
|
||||
try:
|
||||
with zipfile.ZipFile(io.BytesIO(data)) as z:
|
||||
files = z.namelist()
|
||||
print(f"Zip 文件包含 {len(files)} 个文件:{files[:5]}...")
|
||||
# 检查是否包含 base_info.txt
|
||||
if any("base_info.txt" in f for f in files):
|
||||
print("验证成功:包含 base_info.txt")
|
||||
except Exception as e:
|
||||
print(f"Zip 校验失败: {e}")
|
||||
# 打印前 16 字节 hex
|
||||
print(f"Header hex: {data[:16].hex()}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user