From 64db8a1ca5ee800ab5af2bd2eac440bfd2067a91 Mon Sep 17 00:00:00 2001 From: xxm Date: Sun, 16 Aug 2026 17:49:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=84=E5=90=88=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E7=BC=A9=E8=BF=9B=E4=BF=AE=E5=A4=8D+=E5=8D=95=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=97=A8=E6=A7=9B0.5pp+4-6=E5=9B=A0=E5=AD=90=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- evolution/b_group_miner.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/evolution/b_group_miner.py b/evolution/b_group_miner.py index 4d76192a..e2c8d174 100644 --- a/evolution/b_group_miner.py +++ b/evolution/b_group_miner.py @@ -65,26 +65,27 @@ def scan_big(market, regime, panel, min_n=500): if len(m) < 200: continue rate = m["is_big"].mean() * 100 - if rate > br * 1.3: # 大涨率比基线高30% + if rate > br + 0.5: # 单条件提升>0.5pp 进组合池(多因子叠加才有大提升) single.append((feat, round(rate, 1), len(m), round(rate - br, 1))) single.sort(key=lambda x: -x[3]) - print(" 单条件:", single[:5]) + print(" 单条件:", single[:6]) - # 三因子组合(从单条件提升>基线*1.3 里取 6 个) - pool = [s[0] for s in single if s[3] > br * 0.3][:6] + # 4-6 因子组合(从单条件提升>0.5pp 里取 8 个,测 4/5/6 组合) + pool = [s[0] for s in single if s[3] > 0.5][:8] results = [] - for combo in combinations(pool, 3): - cond = pd.Series(True, index=sub.index) - for feat in combo: - op, val = factor_defs[feat] - cond &= (sub[feat] < val) if op == "<" else (sub[feat] > val) - m = sub[cond] - if len(m) < 200: - continue - rate = m["is_big"].mean() * 100 - avg = m["fwd_ret60"].mean() - results.append(({f: factor_defs[f] for f in combo}, len(m), round(rate, 1), - round(avg, 1), round(rate - br, 1))) + for k in [4, 5, 6]: + for combo in combinations(pool, k): + cond = pd.Series(True, index=sub.index) + for feat in combo: + op, val = factor_defs[feat] + cond &= (sub[feat] < val) if op == "<" else (sub[feat] > val) + m = sub[cond] + if len(m) < 200: + continue + rate = m["is_big"].mean() * 100 + avg = m["fwd_ret60"].mean() + results.append(({f: factor_defs[f] for f in combo}, len(m), round(rate, 1), + round(avg, 1), round(rate - br, 1), len(combo))) results.sort(key=lambda x: -x[4]) return results[:5] @@ -140,7 +141,7 @@ def mine(market="a", regimes=None): out = {"market": market, "mined_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "candidates": []} for rg in regimes: combos = scan_big(market, rg, panel) - for cond, n, rate, avg, extra in combos[:3]: + for cond, n, rate, avg, extra, nf in combos[:3]: c = pd.Series(True, index=panel.index) for feat, (op, val) in cond.items(): if feat not in panel.columns: