From 7026959f58ce295e4f025e168f0b0e1fe96cc43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Fri, 10 Jul 2026 00:09:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=A1=E5=8F=B7-=E4=BB=93=E4=BD=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=E6=A0=A1=E9=AA=8C(=E8=A7=82?= =?UTF-8?q?=E6=9C=9B/=E5=8D=96=E5=87=BA=E2=86=920%,=20=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E2=89=A45%)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/batch_reassess.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/batch_reassess.py b/scripts/batch_reassess.py index 5b72556c..c262a63a 100644 --- a/scripts/batch_reassess.py +++ b/scripts/batch_reassess.py @@ -149,20 +149,27 @@ def parse_response(text): nums = re.findall(r'[\d.]+', l) pct = "" if nums: - # 取第一个合理的百分比(1-100之间) for n in nums: f = float(n) if 1 <= f <= 100: pct = f"{f:.0f}%" break - # 如果没有百分比,用文字描述映射到百分比 raw = l.replace("建议仓位","").strip() if not pct: if "轻仓" in raw: pct = "3%" elif "中" in raw and "仓" in raw: pct = "5%" elif "重仓" in raw: pct = "10%" - elif "清仓" in raw or "零仓" in raw: pct = "0%" + elif "清仓" in raw or "零仓" in raw or "不参与" in raw: pct = "0%" else: pct = "5%" + # 信号与仓位一致性校验 + if result["signal"] in ("观望", "卖出"): + pct = "0%" + elif result["signal"] == "关注": + # 关注信号仓位不超过5% + if pct and pct != "0%": + pct_num = int(pct.replace("%","")) + if pct_num > 5: + pct = "5%" result["position"] = pct break