fix: 普适指标真实化——trades月份去重/温区总月份(原信号÷3估算使s2_panic虚高100分)
This commit is contained in:
@@ -56,6 +56,8 @@ def create_table(conn):
|
||||
positions_taken INTEGER,
|
||||
sharpe_ratio REAL,
|
||||
profit_factor REAL,
|
||||
universality_months INTEGER,
|
||||
universality_score REAL,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (strategy, market, regime, period_tag)
|
||||
)
|
||||
@@ -158,17 +160,24 @@ def process_period(conn, market, period_tag):
|
||||
cagr = round(((1 + ret / 100) ** (365 / span_days) - 1) * 100, 1)
|
||||
else:
|
||||
cagr = None
|
||||
# 普适:该温区 trades 的 entry_date 去重月份数 / 该温区总月份数(2026-08-16 修复:
|
||||
# 原 server 端信号数÷3估算 → s2_panic 2255信号估算751月=100分,实际只2个月)
|
||||
_uniq_months = len({t.get("entry_date", "")[:7] for t in reg_trades if t.get("entry_date")})
|
||||
_regime_months_all = {d[:7] for d, r in rmap.items() if r == reg}
|
||||
_regime_total_months = len(_regime_months_all)
|
||||
_univ_score = round(min(_uniq_months / max(_regime_total_months, 1) * 100, 100)) if _uniq_months else 0
|
||||
conn.execute(
|
||||
"""INSERT OR REPLACE INTO strategy_regime_perf_by_period
|
||||
(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, updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||
positions_taken, sharpe_ratio, profit_factor, universality_months, universality_score, updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||
(v, market, reg, period_tag, len(reg_trades),
|
||||
extra.get("win_rate"), extra.get("avg_pnl"), extra.get("avg_hold_days"),
|
||||
ret, cagr, sim.get("portfolio_max_dd_pct"),
|
||||
sim.get("capital_final"), sim.get("positions_taken"),
|
||||
extra.get("sharpe_ratio"), extra.get("profit_factor"), now))
|
||||
extra.get("sharpe_ratio"), extra.get("profit_factor"),
|
||||
_uniq_months, _univ_score, now))
|
||||
written += 1
|
||||
return written
|
||||
|
||||
|
||||
Reference in New Issue
Block a user