fix: 普适指标真实化——trades月份去重/温区总月份(原信号÷3估算使s2_panic虚高100分)
This commit is contained in:
@@ -60,7 +60,8 @@ def _compute_regime_winrates_cached(pt, _approx_univ):
|
||||
for _r in _c.execute(
|
||||
"SELECT strategy, market, regime, period_tag, trades, win_rate, avg_pnl, "
|
||||
"avg_hold_days, total_return_pct, cagr_pct, portfolio_max_dd_pct, capital_final, "
|
||||
"positions_taken, sharpe_ratio, profit_factor FROM strategy_regime_perf_by_period "
|
||||
"positions_taken, sharpe_ratio, profit_factor, universality_months, universality_score "
|
||||
"FROM strategy_regime_perf_by_period "
|
||||
"WHERE period_tag=? ORDER BY strategy, market, regime",
|
||||
(_pt_use,)).fetchall():
|
||||
_ver, _mkt, _reg = _r[0], _r[1], _r[2]
|
||||
@@ -71,6 +72,8 @@ def _compute_regime_winrates_cached(pt, _approx_univ):
|
||||
_pt_v = _r[12]
|
||||
_sh_v = _r[13]
|
||||
_pf_v = _r[14]
|
||||
_umon = _r[15]
|
||||
_uscore = _r[16]
|
||||
_regime_winrates.setdefault(_ver, {})[_reg] = {
|
||||
"trades": _r[4], "win_rate": _r[5], "avg_pnl": _r[6],
|
||||
"avg_hold_days": _r[7],
|
||||
@@ -83,7 +86,7 @@ def _compute_regime_winrates_cached(pt, _approx_univ):
|
||||
"portfolio_max_dd_pct": _dd_v, "capital_final": _cf_v,
|
||||
"positions_taken": _pt_v, "sharpe_ratio": _sh_v,
|
||||
"profit_factor": _pf_v},
|
||||
"universality": _approx_univ(_ver, _reg, _r[4]),
|
||||
"universality": _approx_univ(_ver, _reg, _r[4], _umon, _uscore),
|
||||
}
|
||||
_c.close()
|
||||
except Exception:
|
||||
@@ -625,8 +628,11 @@ def get_tracking():
|
||||
@app.route("/api/research/strategies")
|
||||
def api_research_strategies():
|
||||
"""策略版本列表(含回测结果摘要,支持 period_tag 区间过滤)"""
|
||||
def _approx_regime_universality(strategy, regime, trades):
|
||||
"""温区级普适近似:温区内信号月份≈trades/温区月均笔数,温区总月份占比(避免逐笔遍历性能问题)"""
|
||||
def _approx_regime_universality(strategy, regime, trades, umon=None, uscore=None):
|
||||
"""温区级普适:优先用预计算真实值(trades entry_date 去重月份/温区总月份),
|
||||
缺失时退回旧近似(信号数÷3估算,2026-08-16 修复——原估算对集中信号虚高)"""
|
||||
if umon is not None and uscore is not None:
|
||||
return {"months": umon, "score": uscore, "regime_total_months": 0}
|
||||
try:
|
||||
import sqlite3 as _sq6
|
||||
_c6 = _sq6.connect(str(DATA_DIR / "mofin.db"), timeout=10)
|
||||
|
||||
Reference in New Issue
Block a user