From 30dbb8a667cc9b38e6a0fde943a4716855ee3997 Mon Sep 17 00:00:00 2001 From: xxm Date: Mon, 24 Aug 2026 11:08:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A8=E8=8D=90=E9=93=BE=E8=B7=AF+?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=B7=AF=E7=94=B15=E4=BF=AE=E2=80=94?= =?UTF-8?q?=E2=80=94=E2=91=A0push=5Frecommend=5Falert=20notify=E6=9C=AA?= =?UTF-8?q?=E5=AF=BC=E5=85=A5(=E6=8E=A8=E8=8D=90=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E5=85=A8=E7=81=AD=E6=A0=B9=E5=9B=A0)=E2=91=A1action=E5=88=A4?= =?UTF-8?q?=E9=87=8D(=E6=B7=B1=E5=A5=97=E6=8C=81=E6=9C=89=E9=87=8D?= =?UTF-8?q?=E5=A4=8D)=E2=91=A2518880=E6=88=90=E6=9C=AC=E5=88=97=E9=94=99?= =?UTF-8?q?=E4=BD=8Dh[2]shares=E2=86=92h[3]cost=E2=91=A3=5Fpush=5Faction?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E8=B7=AF=E7=94=B1:=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=89=8D=E4=B8=8AXMPP,=E5=BC=82=E5=8A=A8/?= =?UTF-8?q?=E6=AD=A2=E6=8D=9F/=E6=80=A5=E8=B7=8C=E5=8F=AA=E8=BF=9Bbroadcas?= =?UTF-8?q?t=E2=91=A4anomaly=5Fmonitor=20delivery=E2=86=92broadcast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/anomaly_monitor.py | 2 +- deploy/profile-scripts/mofin_db.py | 4 ++++ deploy/profile-scripts/price_monitor.py | 19 ++++++++++++------- deploy/profile-scripts/strategy_lifecycle.py | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/deploy/profile-scripts/anomaly_monitor.py b/deploy/profile-scripts/anomaly_monitor.py index 8024f455..df020e5a 100644 --- a/deploy/profile-scripts/anomaly_monitor.py +++ b/deploy/profile-scripts/anomaly_monitor.py @@ -80,7 +80,7 @@ def get_holdings(): codes = set(h[0] for h in holds) | set(w[0] for w in wl) names = {h[0]: h[1] or h[0] for h in holds} names.update({w[0]: w[1] or w[0] for w in wl}) - costs = {h[0]: h[2] for h in holds} + costs = {h[0]: h[3] for h in holds} # 2026-08-24 修复列错位:h[2]=shares h[3]=cost(518880成本2400 bug) return codes, names, costs def check_anomalies(): diff --git a/deploy/profile-scripts/mofin_db.py b/deploy/profile-scripts/mofin_db.py index f82de1d8..d10776e3 100644 --- a/deploy/profile-scripts/mofin_db.py +++ b/deploy/profile-scripts/mofin_db.py @@ -1962,6 +1962,10 @@ def push_recommend_alert(conn, code: str): """推荐操作 XMPP 推送(tag 转为 current_recommend 时调用,全路径统一)。 质量门禁:实时价>0、区间有效(下沿<上沿<下沿x3)、现价不超上沿5%、 损<下沿且在(0.5x~1.0x)现价内、盈>上沿>损。不过不推。""" + try: + from alert_helper import notify, ACTION # 2026-08-24 修复 name 'notify' is not defined + except Exception: + notify, ACTION = None, "ACTION" try: row = conn.execute( "SELECT name, timing_signal, entry_low, entry_high, stop_loss, take_profit, " diff --git a/deploy/profile-scripts/price_monitor.py b/deploy/profile-scripts/price_monitor.py index 21b2a94d..5383fbef 100644 --- a/deploy/profile-scripts/price_monitor.py +++ b/deploy/profile-scripts/price_monitor.py @@ -199,16 +199,21 @@ def push_to_xmpp(text): # ACTION: 破止损/重评确认的操作信号 — 直通不限速 # INFO: 未确认的进区提示 — 聚合成摘要,30min 限 1 条 def _push_action(category, text): - # 统一消息处理者:操作推荐→broadcast归档+xmpp推送 + # 2026-08-24 老莫新规则:只有含"操作建议"的消息才上 XMPP(操作信号/推荐); + # 无操作建议的异动播报/止损告警/急跌告警只进 broadcast,不打扰 + _XMPP_CATS = ("操作信号", "重点推荐", "推荐操作") + _is_advice = category in _XMPP_CATS try: - messenger_send(title=f"MoFin持仓异动", content=text, source="price_monitor.py") + messenger_send(title=f"MoFin持仓异动", content=text, source="price_monitor.py", + channel="xmpp" if _is_advice else "broadcast") except Exception as e: print(f"[messenger失败] {e}", file=sys.stderr) - try: - from alert_helper import notify, ACTION - notify(category, text, ACTION) - except Exception as e: - print(f"[ACTION推送失败] {e}", file=sys.stderr) + if _is_advice: + try: + from alert_helper import notify, ACTION + notify(category, text, ACTION) + except Exception as e: + print(f"[ACTION推送失败] {e}", file=sys.stderr) def _push_digest(category, text): diff --git a/deploy/profile-scripts/strategy_lifecycle.py b/deploy/profile-scripts/strategy_lifecycle.py index 7a63297f..c5d88353 100644 --- a/deploy/profile-scripts/strategy_lifecycle.py +++ b/deploy/profile-scripts/strategy_lifecycle.py @@ -1584,11 +1584,11 @@ def reassess_strategy(code, name, price, cost, shares, current_action, else: action_parts.append("盈利良好") - if action_note: + if action_note and action_note not in action_parts: # 2026-08-24 判重:深套持有|深套持有 重复 action_parts.append(action_note) # 量价分析描述(如有,注入action) - if vol_pattern_note: + if vol_pattern_note and vol_pattern_note not in action_parts: action_parts.append(vol_pattern_note) if is_watchlist: