Files
tick-stock-panel/backend/tests/test_resolve_universe_index.py
T
shy3130 ecb49cbaca release: v0.3.6 — 核心+扩展架构完善版
合并 0.3.6 分支全部内容 (36 提交, 详细历史见 0.3.6 分支):

■ 数据与插件
- TdxQuant 数据源: 通达信量化接入 (实时/五档/日K/复权/分钟), tdxaidata 收进默认依赖
- 扩展表两级拉取配方: 概念/行业出厂即带完整可拉配置, 可作自定义接入参考示例
- 能力门禁日志带生效源; 标的池解析只走 instruments 维表

■ 页面扩展化
- 11 个官方页面全量迁移为单文件扩展 (custom/*/extension.tsx), 删目录即卸载
- 运行时页面包系统: 打包产物上传即挂载, 免重建宿主
- 新装用户扩展页默认隐藏, 老用户升级菜单无感

■ AI
- Responses 协议接入; 会话历史与长任务跨设备同步 (服务端注册表)
- 助手头部快捷入口 + 悬浮球拖拽 zoom 坐标系修复 + 系统设置开关

■ 界面
- 设置「关于」子菜单: 版权/更新/打赏 + 开源许可弹窗与合规声明双保险
- 侧栏两态收起、数据/AI 助手快捷行 (同步呼吸光晕)、核心/扩展 ext 标记
- 界面缩放默认 90%; 菜单设置徽标 Swiss 化; 策略池「叠加」分组
- 情绪评分口径可配置; 财务画像 5 张子表手动拉取

■ 文档与其他
- README 重构「核心+扩展」主线 + 架构图重画; 开放端点数核实为 65
- 版本号 bump 0.3.6; tdx 物化库测试夹具补 macOS dylib
2026-10-13 13:40:17 +08:00

70 lines
2.5 KiB
Python

"""_resolve_universe 维表单一来源 + 指数过滤测试。"""
import polars as pl
import pytest
from app.jobs import daily_pipeline
from app.tickflow.repository import DataStore, KlineRepository
@pytest.fixture()
def repo(tmp_path):
return KlineRepository(DataStore(tmp_path))
class _Capset:
def __init__(self, has_batch: bool = False):
self._has_batch = has_batch
def has(self, cap):
return self._has_batch
def _write_instruments(tmp_path, symbols):
out = tmp_path / "instruments" / "instruments.parquet"
out.parent.mkdir(parents=True, exist_ok=True)
pl.DataFrame({"symbol": symbols}).write_parquet(out)
def test_resolve_universe_excludes_index_symbols(repo, monkeypatch, tmp_path):
"""自选里的指数不进入股票日K/分钟K同步池。"""
_write_instruments(tmp_path, ["600000.SH"])
monkeypatch.setattr(
daily_pipeline, "get_pool",
lambda name, refresh=False: ["600000.SH", "000001.SH"] if name == "watchlist" else [],
)
monkeypatch.setattr(daily_pipeline.settings, "data_dir", tmp_path)
monkeypatch.setattr(repo, "get_index_symbol_set", lambda: {"000001.SH"})
universe = daily_pipeline._resolve_universe(_Capset(), repo)
assert "600000.SH" in universe
assert "000001.SH" not in universe
def test_resolve_universe_never_fetches_pools(repo, monkeypatch, tmp_path):
"""维表单一来源: 即使有 batch 能力也不拉 CN_Equity_A 池 (SW1 兜底随之消失)。"""
def _guard(name, refresh=False):
if name != "watchlist":
raise AssertionError(f"不得拉取标的池: {name}")
return ["600000.SH"]
_write_instruments(tmp_path, ["000001.SZ"])
monkeypatch.setattr(daily_pipeline, "get_pool", _guard)
monkeypatch.setattr(daily_pipeline.settings, "data_dir", tmp_path)
monkeypatch.setattr(repo, "get_index_symbol_set", lambda: set())
universe = daily_pipeline._resolve_universe(_Capset(has_batch=True), repo)
assert universe == ["000001.SZ", "600000.SH"]
def test_resolve_universe_watchlist_only_when_no_table(repo, monkeypatch, tmp_path):
"""维表缺失时不伪造标的: 池=自选, 宁缺毋假。"""
monkeypatch.setattr(
daily_pipeline, "get_pool",
lambda name, refresh=False: ["600000.SH"] if name == "watchlist" else [],
)
monkeypatch.setattr(daily_pipeline.settings, "data_dir", tmp_path)
monkeypatch.setattr(repo, "get_index_symbol_set", lambda: set())
universe = daily_pipeline._resolve_universe(_Capset(), repo)
assert universe == ["600000.SH"]