diff --git a/deploy/profile-scripts/regime_perf_by_period.py b/deploy/profile-scripts/regime_perf_by_period.py index ae8b20cd..2af55711 100644 --- a/deploy/profile-scripts/regime_perf_by_period.py +++ b/deploy/profile-scripts/regime_perf_by_period.py @@ -147,9 +147,17 @@ def process_period(conn, market, period_tag): if not sim: continue ret = sim.get("total_return_pct") - # 线性年化:收益 × (窗口总天数 / 该温区窗口内天数) - rd = reg_days.get(reg, 0) - cagr = round(ret * (total_days / rd), 1) if ret is not None and rd > 0 and total_days > 0 else None + # 复利年化(2026-08-16 修正):按该温区 trades 实际时间跨度 + # 原线性放大 ret×(total_days/rd) 对高频复利策略失真(b_td1 388%×4=1547%) + _eds = [t.get("entry_date") for t in reg_trades if t.get("entry_date")] + if ret is not None and _eds: + from datetime import datetime as _dt + _d0 = _dt.strptime(min(_eds), "%Y-%m-%d") + _d1 = _dt.strptime(max(_eds), "%Y-%m-%d") + span_days = max((_d1 - _d0).days, 30) + cagr = round(((1 + ret / 100) ** (365 / span_days) - 1) * 100, 1) + else: + cagr = None conn.execute( """INSERT OR REPLACE INTO strategy_regime_perf_by_period (strategy, market, regime, period_tag, trades, win_rate, avg_pnl, avg_hold_days,