mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 18:04:20 +08:00
用户反馈 get_history_fund_flow(SH, "600519") 返回空 DataFrame,日志显示 "K线响应为空(声称 800 条但首条即解析失败...)"。排查定位:当前 host 对 常见标的也返回 ret_count 撒谎的空 body,但资金流兼容回退路径(直连空 → 拉 K 线 + 历史逐笔重算)未接入 v1.20.4 的空数据故障转移,"服务器回包正常 但内容是假的空" 既非 TdxConnectionError 也不触发换台,用户卡在坏服务器上。 修复:get_history_fund_flow(sync+async)当前 host 直连与 K 线回退均空时, 按延迟顺序逐台实测找首台返回有效数据的服务器(与 get_security_bars/ get_index_bars 同源逻辑)。因资金流获取涉及多命令,无法用单 cmd 复用泛化版 _find_host_returning_data,故内联 _fund_flow_failover:每台候选上跑完整 _fetch_fund_flow_records(原直连+K线回退逻辑抽出成独立方法),返回首台非空 结果。全空返回空 DataFrame(不 raise,区分"真无历史数据"与"服务器缺数据")。 测试:新增 6 个(4 sync + 2 async)。全套 989 passed;ruff/mypy 改动文件零错误。
86 lines
2.7 KiB
TOML
86 lines
2.7 KiB
TOML
[build-system]
|
||
requires = ["hatchling"]
|
||
build-backend = "hatchling.build"
|
||
|
||
[project]
|
||
name = "easy-tdx"
|
||
version = "1.20.5"
|
||
description = "通达信 TCP 协议行情数据客户端,支持在线行情、离线数据读取与写入同步"
|
||
readme = "README.md"
|
||
requires-python = ">=3.10"
|
||
dependencies = ["pandas>=2.0,<3", "tzdata>=2024.1", "click>=8.0,<9"]
|
||
|
||
[project.scripts]
|
||
easy-tdx = "easy_tdx.cli:cli" # cli/__init__.py exposes the click group
|
||
|
||
[project.optional-dependencies]
|
||
dev = ["pytest>=8.0", "pytest-asyncio>=0.23", "pytest-cov", "mypy>=1.9", "ruff>=0.4", "scipy>=1.10,<1.16", "httpx>=0.27"]
|
||
science = ["scipy>=1.10,<1.16"]
|
||
web = ["fastapi>=0.110,<1", "uvicorn[standard]>=0.29"]
|
||
# 打包成桌面 EXE 用:系统托盘(pystray)+ 图标生成(Pillow)。
|
||
# 仅 PyInstaller 打包态需要,开发态 ``pip install -e .[web]`` 不强制装。
|
||
packaging = ["pystray>=0.19", "Pillow>=10.0"]
|
||
|
||
[tool.hatch.build]
|
||
# 前端 dist 是构建产物(在 .gitignore 里),hatchling 默认不打包。
|
||
# artifacts 让它被 sdist 和 wheel 都强制包含。
|
||
artifacts = [
|
||
"web-ui/dist/",
|
||
]
|
||
|
||
[tool.hatch.build.targets.wheel]
|
||
packages = ["src/easy_tdx"]
|
||
# 前端 dist 映射到包内 easy_tdx/web/dist/。CI(ci.yml)、publish(publish.yml)
|
||
# 和 release(release.yml)都会在 pip install / build 前先 npm run build。
|
||
force-include = { "web-ui/dist" = "easy_tdx/web/dist" }
|
||
|
||
[tool.mypy]
|
||
strict = true
|
||
python_version = "3.12"
|
||
# 跳过未跟踪的本地脚本(依赖外部 unified_config/sqlalchemy/requests,不属于库)
|
||
exclude = ["src/easy_tdx/exchange_margin\\.py"]
|
||
|
||
[[tool.mypy.overrides]]
|
||
module = ["pandas", "tabulate", "matplotlib", "matplotlib.*"]
|
||
ignore_missing_imports = true
|
||
|
||
[[tool.mypy.overrides]]
|
||
module = "easy_tdx.MyTT"
|
||
# Type stubs provided via MyTT.pyi — keep strict checks enabled
|
||
|
||
[[tool.mypy.overrides]]
|
||
module = ["fastapi.*", "uvicorn.*", "pydantic.*"]
|
||
ignore_missing_imports = true
|
||
|
||
[[tool.mypy.overrides]]
|
||
# pystray / Pillow 无 type stubs;tray.py 已用 type: ignore 兜底关键调用
|
||
module = ["pystray", "pystray.*", "PIL", "PIL.*"]
|
||
ignore_missing_imports = true
|
||
|
||
[[tool.mypy.overrides]]
|
||
module = ["scipy", "scipy.*"]
|
||
ignore_missing_imports = true
|
||
|
||
[tool.ruff]
|
||
target-version = "py310"
|
||
line-length = 100
|
||
extend-exclude = ["*.pyi", "src/easy_tdx/exchange_margin.py"]
|
||
|
||
[tool.ruff.lint]
|
||
select = ["E", "F", "I", "UP"]
|
||
|
||
[tool.pytest.ini_options]
|
||
testpaths = ["tests"]
|
||
addopts = "--tb=short"
|
||
asyncio_mode = "auto"
|
||
|
||
[tool.coverage.run]
|
||
source = ["easy_tdx"]
|
||
omit = ["tests/*"]
|
||
|
||
[tool.coverage.report]
|
||
# 覆盖率门槛。从 50 提升到 60(审计 #9):补充 reconnect/bitmap/config 测试后
|
||
# 实测约 61%。进一步提到 70 需补 web/ 路由与更多 client 镜像测试,留待后续。
|
||
fail_under = 60
|
||
show_missing = true
|