[project] name = "tickflow-stock-panel-backend" version = "0.4.1" description = "A 股策略 + 监控 + 回测面板 — TickFlow 适配" requires-python = ">=3.11" license = { text = "MIT" } dependencies = [ "tivelo-extensions>=0.1.0a1,<0.2", "tivelo-contracts[signatures]>=0.1.0a1,<0.2", "tivelo-data[cn-fuyao,cn-tdxquant,cn-tickflow]>=0.1.0a1,<0.2", "tivelo-market-cn>=0.1.0a1,<0.2", "tivelo-backtest>=0.1.0a1,<0.2", "keyring>=25,<27; sys_platform == 'darwin' or sys_platform == 'win32'", # Web "fastapi>=0.115", "uvicorn[standard]>=0.30", "pydantic>=2.7", "pydantic-settings>=2.4", "python-multipart>=0.0.6", "sse-starlette>=2.0", # Data # 1.44 起含流式引擎 executor 线程调度修复; 上限锁定一个已验证的大版本, # 升级需重跑 scripts/stress_polars_concurrency.py 压测 (并发死锁回归)。 "polars>=1.44,<1.45", "duckdb>=1.0", "pyarrow>=16.0", "psutil>=5.9", # 独立回测 worker 的峰值 RSS 与退出后内存指标 # llvmlite 不再提供 macOS Intel wheel;该平台使用 Matrix 纯 Python fallback。 "numba>=0.65.1; sys_platform != 'darwin' or platform_machine != 'x86_64'", "fastexcel>=0.10", # Polars 读取 xlsx/xls "pypinyin>=0.50", # 股票名拼音首字母搜索 (同花顺式 payh → 平安银行) # TickFlow 官方 SDK "tickflow[all]>=0.1.23", # TdxQuant 内置数据源插件的原生 TCP 客户端 (wheel 自带跨平台库, 无需系统依赖) "tdxaidata>=1.2.2", # Scheduling "apscheduler>=3.10", # Config "pyyaml>=6.0", "packaging>=24.0", # 外部插件版本与依赖兼容范围 "python-dotenv>=1.0", # AI(可选,但默认装上) "openai>=1.66", # OpenAI 兼容适配器复用 openai SDK; 1.66+ 提供 Responses API "httpx>=0.27", "platformdirs>=4.0", # 桌面版用户数据目录 (跨平台持久可写) "winotify>=1.1; sys_platform == 'win32'", # Windows 系统通知 (进操作中心) "plyer>=2.1", # 系统通知跨平台兜底 (macOS/Linux) # Watchlist screenshot OCR (Tesseract) "pytesseract>=0.3.10", "Pillow>=10.0", ] [project.optional-dependencies] # Legacy CPU runtime: install the Polars compatibility kernel on # machines without AVX2/FMA support. # Enable with: uv sync --extra legacy-cpu legacy-cpu = [ "polars[rtcompat]>=1.44,<1.45", ] # 兼容旧部署脚本,回测引擎已包含在基础依赖中。 backtest = [] # 桌面客户端依赖: pywebview 桌面窗口。打包用 (PyInstaller), 生产/Docker 不需要。 # 启用:`uv sync --extra desktop` desktop = [ "pywebview>=5.0", "tivelo-extensions[linux-desktop]>=0.1.0a1,<0.2; sys_platform == 'linux'", ] dev = [ "pytest>=8.0", "pytest-asyncio>=0.23", "ruff>=0.5", "mypy>=1.10", ] [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [tool.uv.sources] tivelo-extensions = { path = "../packages/tivelo-extensions", editable = true } tivelo-contracts = { path = "../packages/tivelo-contracts", editable = true } tivelo-data = { path = "../packages/tivelo-data", editable = true } tivelo-market-cn = { path = "../packages/tivelo-market-cn", editable = true } tivelo-backtest = { path = "../packages/tivelo-backtest", editable = true } [tool.hatch.build.targets.wheel] packages = ["app"] [tool.ruff] line-length = 100 target-version = "py311" [tool.ruff.lint] # BLE = flake8-blind-except: 禁止 `except Exception` 不留痕。 # 加它的理由: 本仓原有 271 处 `# noqa: BLE001` 而 `BLE` 竟未启用 ⇒ 那些 noqa 全是 # "无效指令"(RUF100), 即「禁止裸 except」当时**完全没有被强制**。启用后: # ①271 条既有 noqa 立即可用(实测 RUF100 293→46) ②将来新增的裸 except 必须显式承认。 # 实测本仓 backend/app: 1420 条 ⇒ 忽略 RUF001/2/3 后 611 条(其中 6 条是原先给 RUF001/2/3 # 写的 noqa 变为"无效指令") ⇒ 再启用 BLE 后 594 条(净减 826)。 # ⚠️ 仍会暴露 236 处**尚未表态**的 `except Exception`(soft-failure 设计, 见 CONTRIBUTING); # 待工作区干净时用 `ruff check --select BLE001 --add-noqa` 批量显式承认, 不在有他人 # 未提交改动时做(会与在途改动冲突)。 # ⚠️ 本仓 CI 目前**不跑 ruff**(ci.yml 只有 `uv run pytest tests -q`) ⇒ 本改动不会打断 CI; # 但正因如此, 这条门禁从来没人守——本改动让它**可执行**, 代价是 236 条既有沉默违规显形。 select = ["E", "F", "I", "N", "UP", "B", "SIM", "RUF", "BLE"] ignore = [ "E501", # 长行交给 fmt # 本仓注释/文档字符串以中文书写, 全角标点(,。:()×)是正常书写而非笔误。 # 不忽略会让「ruff error 清零」永远不可达: 实测 backend/app 共 1420 条告警, # 其中 RUF001/2/3 占 815 条(57.4%) ⇒ 忽略后降到 605 条, 门禁才谈得上可执行。 "RUF001", # String contains ambiguous unicode character "RUF002", # Docstring contains ambiguous unicode character "RUF003", # Comment contains ambiguous unicode character ] [tool.pytest.ini_options] asyncio_mode = "auto"