feat: 策略三状态模型——派生(不存储)激活/可用未激活/不可用+前端三分组展示(不可用淡显折叠)+可用徽章,与候选池(regime_perf+hk_strategies)对齐

This commit is contained in:
xxm
2026-08-15 13:02:34 +08:00
parent b0056e06ef
commit aba860131d
2 changed files with 30 additions and 6 deletions
+16
View File
@@ -628,6 +628,7 @@ def api_research_strategies():
_c2.close()
except Exception:
pass
_candidate_pool |= set(_regime_winrates.keys())
for s in strats:
# 2026-08-15 温区加权综合/普适:整体行的综合/普适 = 按温区时长占比加权各温区表现
# (业务逻辑:策略只在特定温区激活,评估应该限定在温区范围才值得参考)
@@ -684,6 +685,19 @@ def api_research_strategies():
s['current'] = s['version'] in _active_set
# 2026-08-15 证伪数据驱动:从 strategy_research.deprecated 读(替代前端硬编码)
s['deprecated'] = _deprecated.get(s['version'])
# 2026-08-15 三状态(派生,不存储):激活/可用未激活/不可用
if s['version'] in _active_set:
s['state'] = 'active'
s['state_reason'] = '当前温区路由激活'
elif s.get('deprecated'):
s['state'] = 'unavailable'
s['state_reason'] = '已证伪: ' + str(s['deprecated'])[:80]
elif s['version'] in _candidate_pool:
s['state'] = 'available'
s['state_reason'] = '候选池内,当前温区未激活(温区切换即可激活)'
else:
s['state'] = 'unavailable'
s['state_reason'] = '不在候选池(历史版本,路由不会选中)'
# 2026-08-13 关键修复:激活策略必须始终在列表中(即使该 period 无回测记录)
# 否则 2y 等默认周期下激活策略缺失(只显示 v_oversold)。
@@ -712,6 +726,8 @@ def api_research_strategies():
}
_entry['regime_winrates'] = _regime_winrates.get(_mv, {})
_entry['current'] = True
_entry['state'] = 'active'
_entry['state_reason'] = '当前温区路由激活'
_entry['note'] = f"({pt or '当前周期'}无回测记录,显示10y数据)"
strats.append(_entry)
return jsonify({'strategies': strats, 'regime_active': sorted(_active_set)})