mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 21:24:16 +08:00
- 市场环境: 新增情绪周期6阶段(冰点/启动/主升/高潮/退潮/修复, 连板梯队驱动, EMA平滑+2日确认+弱档否决, 平均段长9.7天)与概念/行业主线排名(涨停梯队聚合, 可配置宽基/风格标签过滤); 市场环境页重构, regime 透明加列, 与5档state并存 - 挖掘: 因子与策略挖掘全链路(API/worker/进程锁/候选库/前端工作台/文档), 周度调度默认关闭且永不自动发布 - 回测: 财务快照因子(点时口径), 批量回测预计算共享下期收益, 信号路径矩阵列依赖展开修复(consecutive_limit_ups 缺列报错) - 数据/性能: enriched 生成与预热治理, 重任务限流, 行情/K线缓存复用, 时区修复 - 测试: 后端全量 914 通过; GUI 黑盒验证截图存证 gui-test-screenshots/
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import polars as pl
|
|
import pytest
|
|
|
|
from app.indicators import pipeline
|
|
from app.services.quote_service import QuoteService
|
|
|
|
|
|
def _today_rows(turnover_rate: float | None = None) -> pl.DataFrame:
|
|
row = {
|
|
"symbol": "600000.SH",
|
|
"open": 10.0,
|
|
"high": 10.0,
|
|
"low": 10.0,
|
|
"close": 10.0,
|
|
"raw_close": 10.0,
|
|
"raw_high": 10.0,
|
|
"raw_low": 10.0,
|
|
"volume": 8000.0,
|
|
}
|
|
if turnover_rate is not None:
|
|
row["turnover_rate"] = turnover_rate
|
|
return pl.DataFrame([row])
|
|
|
|
|
|
def _instruments() -> pl.DataFrame:
|
|
return pl.DataFrame({
|
|
"symbol": ["600000.SH"],
|
|
"name": ["Test"],
|
|
"float_shares": [100_000_000.0],
|
|
})
|
|
|
|
|
|
def test_quote_extra_normalizes_realtime_turnover_fraction_to_percent_value():
|
|
out = QuoteService._build_quote_extra([{"symbol": "600000.SH", "turnover_rate": 0.008}])
|
|
|
|
assert out["turnover_rate"][0] == pytest.approx(0.8)
|
|
|
|
|
|
def test_realtime_turnover_rate_uses_api_value_directly_after_entry_normalization():
|
|
out = pipeline._compute_limit_signals_today(_today_rows(0.8), _instruments())
|
|
|
|
assert out["turnover_rate"][0] == pytest.approx(0.8)
|
|
|
|
|
|
def test_realtime_turnover_rate_falls_back_to_float_shares_when_missing():
|
|
out = pipeline._compute_limit_signals_today(_today_rows(), _instruments())
|
|
|
|
assert out["turnover_rate"][0] == pytest.approx(0.8)
|