fix: 淘汰判定改直接读预计算表(2y/10y)——不再依赖已废弃的内存缓存,读表毫秒级

This commit is contained in:
xxm
2026-08-15 22:55:15 +08:00
parent a95566f2e0
commit db9f41ce50
+11 -17
View File
@@ -730,23 +730,17 @@ def api_research_strategies():
_elim_reason = None _elim_reason = None
try: try:
_b2, _b10 = _get_benchmarks() _b2, _b10 = _get_benchmarks()
if _b2 is not None and _b10 is not None and pt in ('2y', '10y'): if _b2 is not None and _b10 is not None:
_r2 = _regime_winrates if pt == '2y' else None # 读表拿 2y/10y 温区数据(毫秒级,数据加工层预计算)
_r10 = _regime_winrates if pt == '10y' else None _r2 = _compute_regime_winrates_cached('2y', _approx_regime_universality)
# 缓存里拿另一周期(命中才判定,未命中本轮跳过) _r10 = _compute_regime_winrates_cached('10y', _approx_regime_universality)
_slots_c = _regime_winrates_cache.get("slots") or {} _v2 = _r2.get(s['version']) or {}
if _r2 is None and ('2y' in _slots_c): _v10 = _r10.get(s['version']) or {}
_r2 = _slots_c['2y'][1] if _v2 and _v10:
if _r10 is None and ('10y' in _slots_c): _best2 = max(r.get('cagr_pct') or -999 for r in _v2.values())
_r10 = _slots_c['10y'][1] _best10 = max(r.get('cagr_pct') or -999 for r in _v10.values())
if _r2 is not None and _r10 is not None: if _best2 < _b2 and _best10 < _b10:
_v2 = _r2.get(s['version']) or {} _elim_reason = f'2y年化{round(_best2,1)}%<大盘{_b2}% 且 10y年化{round(_best10,1)}%<大盘{_b10}%'
_v10 = _r10.get(s['version']) or {}
if _v2 and _v10:
_best2 = max(r.get('cagr_pct') or -999 for r in _v2.values())
_best10 = max(r.get('cagr_pct') or -999 for r in _v10.values())
if _best2 < _b2 and _best10 < _b10:
_elim_reason = f'2y年化{round(_best2,1)}%<大盘{_b2}% 且 10y年化{round(_best10,1)}%<大盘{_b10}%'
except Exception: except Exception:
_elim_reason = None _elim_reason = None
if _elim_reason: if _elim_reason: