feat: 策略数据每日自动更新——period_rollup滑窗派生1y/2y/5y行(锚定数据末端,不覆盖真实记录)+health_monitor数据驱动跟随路由激活集合+regime_perf排序改最长周期优先(防派生行污染温区行)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""health_monitor_daily.py — 策略健康度每日监控(v_weak + v_oversold)
|
||||
"""health_monitor_daily.py — 策略健康度每日监控(数据驱动:跟随 strategy_weights.json 激活集合)
|
||||
|
||||
背景(2026-08-12 事项四:健康监控注册 p_oversold):
|
||||
evolution/health_monitor.py 能算策略健康度(实盘近7天浮盈 vs 回测基线5y 偏差 + 写 strategy_health 表 + 告警),
|
||||
@@ -31,6 +31,29 @@ def _singleton_guard(tag="health_monitor_daily.py"):
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def _load_active_strategies():
|
||||
"""从 strategy_weights.json 读当前激活策略(A股 active + 港股 markets.hk.active)。
|
||||
|
||||
2026-08-15 数据驱动改造:原硬编码 (v_weak, v_oversold),温区切换后激活策略变化
|
||||
但监控集合不跟随,导致激活策略无健康度数据。改为读路由输出,兜底旧二元组。
|
||||
"""
|
||||
import json as _json
|
||||
try:
|
||||
d = _json.loads(Path("/home/hmo/MoFin/data/strategy_weights.json").read_text(encoding="utf-8"))
|
||||
active = list(d.get("active") or [])
|
||||
active += list(((d.get("markets") or {}).get("hk") or {}).get("active") or [])
|
||||
seen, out = set(), []
|
||||
for v in active:
|
||||
if v and v not in seen:
|
||||
seen.add(v)
|
||||
out.append(v)
|
||||
if out:
|
||||
return out
|
||||
except Exception as e:
|
||||
print(f" [warn] 读 strategy_weights.json 失败({e}),兜底 v_weak/v_oversold", flush=True)
|
||||
return ["v_weak", "v_oversold"]
|
||||
|
||||
|
||||
def main():
|
||||
_fd = _singleton_guard()
|
||||
print(f"[health_monitor_daily] {datetime.now().strftime('%H:%M:%S')} 策略健康度监控开始", flush=True)
|
||||
@@ -44,9 +67,11 @@ def main():
|
||||
_spec.loader.exec_module(_m)
|
||||
run_health_check = _m.run_health_check
|
||||
|
||||
# 当前策略:v_weak(实盘在跑)+ v_oversold(新策略上线)
|
||||
# 数据驱动:监控集合 = 路由激活策略(A股+港股),随温区切换自动跟随
|
||||
versions = _load_active_strategies()
|
||||
print(f" 监控策略集合: {versions}", flush=True)
|
||||
results = {}
|
||||
for version in ("v_weak", "v_oversold"):
|
||||
for version in versions:
|
||||
try:
|
||||
r = run_health_check(strategy_version=version)
|
||||
results[version] = r
|
||||
|
||||
Reference in New Issue
Block a user