feat: 淘汰阈值改年化<大盘(适应温区2y+10y)+预取优化(循环外取一次2y/10y温区数据)

This commit is contained in:
xxm
2026-08-15 23:54:03 +08:00
parent 5b0e67ad2b
commit 1f408fd6e5
+12 -10
View File
@@ -689,6 +689,10 @@ def api_research_strategies():
_cb.close()
except Exception:
pass
# ── 淘汰预取:2y/10y 温区数据 + 大盘基准(循环外取一次,避免每策略重复查库)──
_elim_r2 = _compute_regime_winrates_cached('2y', _approx_regime_universality)
_elim_r10 = _compute_regime_winrates_cached('10y', _approx_regime_universality)
_elim_b2, _elim_b10 = _get_benchmarks()
for s in strats:
# 2026-08-15 温区加权综合/普适:整体行的综合/普适 = 按温区时长占比加权各温区表现
# (业务逻辑:策略只在特定温区激活,评估应该限定在温区范围才值得参考)
@@ -755,27 +759,25 @@ def api_research_strategies():
s['state'] = 'unavailable'
s['state_reason'] = '已证伪: ' + str(s['deprecated'])[:80]
elif s['version'] in _candidate_pool:
# ── 2026-08-15 无价值淘汰:适应温区(best_regime) 2y+10y 年化都<0 → 历史 ──
# (老莫逻辑:温区表数据对应适应温区;适应温区都亏的策略无价值)
# ── 2026-08-15 无价值淘汰:适应温区(best_regime) 2y+10y 年化都<大盘 → 历史 ──
_elim_reason = None
try:
_br_v = s.get('best_regime')
if _br_v:
_r2 = _compute_regime_winrates_cached('2y', _approx_regime_universality)
_r10 = _compute_regime_winrates_cached('10y', _approx_regime_universality)
_rw2 = (_r2.get(s['version']) or {}).get(_br_v)
_rw10 = (_r10.get(s['version']) or {}).get(_br_v)
_rw2 = (_elim_r2.get(s['version']) or {}).get(_br_v)
_rw10 = (_elim_r10.get(s['version']) or {}).get(_br_v)
if _rw2 and _rw10:
_c2 = _rw2.get('cagr_pct')
_c10 = _rw10.get('cagr_pct')
if _c2 is not None and _c10 is not None and _c2 < 0 and _c10 < 0:
_elim_reason = (f'适应温区[{_br_v}] 2y年化{round(_c2,1)}%<0 '
f'且 10y年化{round(_c10,1)}%<0')
if _c2 is not None and _c10 is not None \
and _c2 < _elim_b2 and _c10 < _elim_b10:
_elim_reason = (f'适应温区[{_br_v}] 2y年化{round(_c2,1)}%<大盘{_elim_b2}% '
f'且 10y年化{round(_c10,1)}%<大盘{_elim_b10}%')
except Exception:
_elim_reason = None
if _elim_reason:
s['state'] = 'unavailable'
s['state_reason'] = '适应温区亏损已淘汰: ' + _elim_reason
s['state_reason'] = '适应温区跑不赢大盘已淘汰: ' + _elim_reason
else:
s['state'] = 'available'
s['state_reason'] = '候选池内,当前温区未激活(温区切换即可激活)'