From 9549ec44d568e4fb73b87ef018bf3ee82a347584 Mon Sep 17 00:00:00 2001 From: xxm Date: Sat, 15 Aug 2026 22:21:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=A9=E5=8C=BA=E5=B9=B4=E5=8C=96?= =?UTF-8?q?=E6=94=B9=E7=BA=BF=E6=80=A7=E6=94=BE=E5=A4=A7(=E6=94=B6?= =?UTF-8?q?=E7=9B=8A=C3=97=E7=AA=97=E5=8F=A3=E5=A4=A9=E6=95=B0/=E6=B8=A9?= =?UTF-8?q?=E5=8C=BA=E5=A4=A9=E6=95=B0)=E2=80=94=E2=80=94=E6=B6=88?= =?UTF-8?q?=E9=99=A4=E5=A4=8D=E5=88=A9=E7=88=86=E7=82=B8(v=5Flurk=5Fbull?= =?UTF-8?q?=205=E7=AC=94=E5=90=8C=E6=97=A5=E2=86=92463=E4=B8=87%=E5=B9=B4?= =?UTF-8?q?=E5=8C=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index d6004862..ff0c4182 100644 --- a/server.py +++ b/server.py @@ -130,6 +130,22 @@ def _compute_regime_winrates_cached(pt, _approx_univ): if not _trades: continue _rmap = _rmap_a if _mkt != 'hk' else _rmap_hk + # ── 温区天数(该策略 trades 窗口内,线性年化用)── + _pt_days = {"total": 0, "regimes": {}} + try: + _eds = [t.get("entry_date", "") for t in _trades if t.get("entry_date")] + _eds = [d for d in _eds if d in _rmap] + if _eds: + _d_min, _d_max = min(_eds), max(_eds) + _cnt = {} + _tot = 0 + for _d, _reg in _rmap.items(): + if _d_min <= _d <= _d_max: + _tot += 1 + _cnt[_reg] = _cnt.get(_reg, 0) + 1 + _pt_days = {"total": _tot, "regimes": _cnt} + except Exception: + pass _by_regime = _dd(list) for _t in _trades: _ed = _t.get("entry_date", "") @@ -143,8 +159,14 @@ def _compute_regime_winrates_cached(pt, _approx_univ): if not _sim: continue _wr_v = _extra.get("win_rate") - _cagr_v = _sim.get("cagr_pct") + # 2026-08-15 温区年化线性放大:收益 × (窗口总天数/该温区天数),消除复利爆炸 _ret_v = _sim.get("total_return_pct") + _reg_days = (_pt_days.get("regimes") or {}).get(_reg, 0) + _pt_total = _pt_days.get("total", 0) + if _ret_v is not None and _reg_days > 0 and _pt_total > 0: + _cagr_v = round(_ret_v * (_pt_total / _reg_days), 1) + else: + _cagr_v = None _dd_v = _sim.get("portfolio_max_dd_pct") _cf_v = _sim.get("capital_final") _pt_v = _sim.get("positions_taken")