fix: 淘汰判定改直接读预计算表(2y/10y)——不再依赖已废弃的内存缓存,读表毫秒级
This commit is contained in:
@@ -730,23 +730,17 @@ def api_research_strategies():
|
||||
_elim_reason = None
|
||||
try:
|
||||
_b2, _b10 = _get_benchmarks()
|
||||
if _b2 is not None and _b10 is not None and pt in ('2y', '10y'):
|
||||
_r2 = _regime_winrates if pt == '2y' else None
|
||||
_r10 = _regime_winrates if pt == '10y' else None
|
||||
# 缓存里拿另一周期(命中才判定,未命中本轮跳过)
|
||||
_slots_c = _regime_winrates_cache.get("slots") or {}
|
||||
if _r2 is None and ('2y' in _slots_c):
|
||||
_r2 = _slots_c['2y'][1]
|
||||
if _r10 is None and ('10y' in _slots_c):
|
||||
_r10 = _slots_c['10y'][1]
|
||||
if _r2 is not None and _r10 is not None:
|
||||
_v2 = _r2.get(s['version']) or {}
|
||||
_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}%'
|
||||
if _b2 is not None and _b10 is not None:
|
||||
# 读表拿 2y/10y 温区数据(毫秒级,数据加工层预计算)
|
||||
_r2 = _compute_regime_winrates_cached('2y', _approx_regime_universality)
|
||||
_r10 = _compute_regime_winrates_cached('10y', _approx_regime_universality)
|
||||
_v2 = _r2.get(s['version']) or {}
|
||||
_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:
|
||||
_elim_reason = None
|
||||
if _elim_reason:
|
||||
|
||||
Reference in New Issue
Block a user