From 06dccfb2b0ce0158c3c85a8f21227d7572dd02e2 Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 25 Aug 2026 12:11:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20reconcile=E7=BC=A9=E8=BF=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D(SIGNAL=5FJSON=E4=BC=98=E5=85=88=E6=AE=B5=E7=9A=84fall?= =?UTF-8?q?back=E5=9D=97)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/mofin_db.py | 36 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/deploy/profile-scripts/mofin_db.py b/deploy/profile-scripts/mofin_db.py index c79071a8..b18d565f 100644 --- a/deploy/profile-scripts/mofin_db.py +++ b/deploy/profile-scripts/mofin_db.py @@ -1202,17 +1202,31 @@ def reconcile_signal_from_analysis(conn, code: str) -> str: return "" fa, old_sig = row[0] or "", row[1] or "" verdict = "" - for line in fa.split("\n"): - if "【综合结论】" in line: - # 2026-08-25 开头匹配(601866教训:"关注(条件性买入机会)"被顺序扫描误抓"买入") - # 综合结论词的规范位置=【综合结论】之后紧跟的第一个词 - tail = line.split("【综合结论】", 1)[1].strip() - # 长词在前防前缀误抓(弱势持有>持有, 可买入/可加仓>买入) - for s in ("可买入", "可加仓", "弱势持有", "买入", "卖出", "止盈", "关注", "观望", "持有"): - if tail.startswith(s): - verdict = s - break - break + # ── 2026-08-25 机器可读结论优先(SIGNAL_JSON 行存在则直接用,散文匹配降级为兜底)── + _mj = re.search(r'^SIGNAL_JSON:\s*(\{.*\})\s*$', fa, re.M) + if _mj: + try: + import json as _js2 + _sj = _js2.loads(_mj.group(1)) + verdict = _sj.get("signal", "") or "" + # LLM 自己标注 actionable=false 的动作信号 → 直接降级(不再依赖否定词表) + if verdict in ("买入", "可买入", "可加仓") and _sj.get("actionable") is False: + verdict = "关注" + print(f" [RECONCILE] {code} SIGNAL_JSON actionable=false,信号降级为关注", flush=True) + except Exception: + verdict = "" + if not verdict: + for line in fa.split("\n"): + if "【综合结论】" in line: + # 2026-08-25 开头匹配(601866教训:"关注(条件性买入机会)"被顺序扫描误抓"买入") + # 综合结论词的规范位置=【综合结论】之后紧跟的第一个词 + tail = line.split("【综合结论】", 1)[1].strip() + # 长词在前防前缀误抓(弱势持有>持有, 可买入/可加仓>买入) + for s in ("可买入", "可加仓", "弱势持有", "买入", "卖出", "止盈", "关注", "观望", "持有"): + if tail.startswith(s): + verdict = s + break + break if verdict: new_sig = verdict # ── 矛盾降级(2026-07-24 老爸:688660综合结论=买入但操作建议说"继续空仓观望暂不执行")──