mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 16:44:15 +08:00
- 数据路由: get_name_map 合并指数维表; get_enriched_latest_asset("index") 缓存+flush/merge 分支; daily-batch 按资产分组
- 自选: watchlist_enriched 指数分支 + 行级 asset_type 标注
- 监控: MonitorRuleEngine 第三轮指数评估 (signal/price); 指数实时焐热复刻 ETF flush; Free档自选实时资产分流; 规则校验 (禁 strategy/market/ladder/分时信号)
- 隔离: _resolve_universe 过滤指数防污染股票日K/分钟K; 指数轮 reset_strategy_results=False; 策略/回测/screener 零改动
- AI 分析: prompt 指数无财务文案
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""daily-batch 混合资产分组测试。"""
|
|
import datetime as _dt
|
|
|
|
import polars as pl
|
|
import pytest
|
|
|
|
from app.tickflow.repository import DataStore, KlineRepository
|
|
|
|
|
|
@pytest.fixture()
|
|
def repo(tmp_path):
|
|
return KlineRepository(DataStore(tmp_path))
|
|
|
|
|
|
def test_daily_batch_groups_index_symbols(repo, monkeypatch):
|
|
from app.api import kline as kline_api
|
|
|
|
calls = {"stock_batch": [], "index": []}
|
|
|
|
def fake_stock_batch(symbols, start, end, columns=None):
|
|
calls["stock_batch"].append(list(symbols))
|
|
return pl.DataFrame()
|
|
|
|
def fake_index_daily(symbol, start, end, columns=None):
|
|
calls["index"].append(symbol)
|
|
return pl.DataFrame({
|
|
"symbol": [symbol], "date": [_dt.date(2026, 7, 24)],
|
|
"open": [1.0], "high": [1.0], "low": [1.0], "close": [1.0], "volume": [1],
|
|
})
|
|
|
|
monkeypatch.setattr(repo, "get_daily_batch", fake_stock_batch)
|
|
monkeypatch.setattr(repo, "get_index_daily", fake_index_daily)
|
|
monkeypatch.setattr(repo, "get_index_symbol_set", lambda: {"000001.SH"})
|
|
monkeypatch.setattr(repo, "get_etf_symbol_set", lambda: set())
|
|
|
|
state = type("S", (), {"repo": repo})()
|
|
req = type("R", (), {"app": type("A", (), {"state": state})()})()
|
|
|
|
out = kline_api.get_daily_batch(req, {"symbols": ["600000.SH", "000001.SH"], "days": 12})
|
|
assert calls["stock_batch"] == [["600000.SH"]]
|
|
assert calls["index"] == ["000001.SH"]
|
|
assert "000001.SH" in out["data"]
|