From ad859d3297176ccd60b30ea58a49ee9fbe3a6a24 Mon Sep 17 00:00:00 2001 From: xxm Date: Sun, 16 Aug 2026 18:40:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20B=E7=BB=84trades=E8=A1=A5profit=5Fpct+ho?= =?UTF-8?q?ld=5Fdays=E5=AD=97=E6=AE=B5,=E5=85=BC=E5=AE=B9portfolio=5Fsim?= =?UTF-8?q?=E6=B8=A9=E5=8C=BA=E9=A2=84=E8=AE=A1=E7=AE=97(=E5=90=A6?= =?UTF-8?q?=E5=88=99KeyError=E8=A2=AB=E5=90=9E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- evolution/b_group_miner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/evolution/b_group_miner.py b/evolution/b_group_miner.py index 803aa325..f7a5759f 100644 --- a/evolution/b_group_miner.py +++ b/evolution/b_group_miner.py @@ -112,17 +112,22 @@ def _simulate_verify(market, regime, panel, cond, tp=20, sl=10, maxh=40): if ep <= 0: continue res = None - for _, fb in fut.iterrows(): + hold_days = maxh + for j, (_, fb) in enumerate(fut.iterrows()): if fb["close"] <= ep * (1 - sl / 100): res = -sl + hold_days = j + 1 break if fb["close"] >= ep * (1 + tp / 100): res = tp + hold_days = j + 1 break if res is None: res = (fut.iloc[-1]["close"] / ep - 1) * 100 + hold_days = len(fut) trades.append(res) trade_details.append({"entry_date": str(g.loc[i, "date"]), "pnl_pct": round(res, 2), + "profit_pct": round(res, 2), "hold_days": hold_days, "code": str(code)}) if not trades: return None