diff --git a/deploy/profile-scripts/promote_reassess_backfill.py b/deploy/profile-scripts/promote_reassess_backfill.py index 4b1a6185..003f6c48 100644 --- a/deploy/profile-scripts/promote_reassess_backfill.py +++ b/deploy/profile-scripts/promote_reassess_backfill.py @@ -74,19 +74,23 @@ def main(wait_sec=90): f"WHERE status='active' AND code IN ({codes})", tuple(c[0] for c in backfilled)).fetchall() conn.close() - body = f"📤 重评报告补推({len(ready)}只新入自选的重评已就绪)\n" - for i, (code, name, strat, rr, fa) in enumerate(ready, 1): - nm = name or code - body += f"\n━━━ [{i}] {code} {nm} ━━━\n" - body += f"策略: {strat or 'unknown'} | RR: {rr or 'N/A'}\n" - if fa and len(str(fa)) > 50: - body += f"【12维重评】\n{fa}\n" - else: - body += "(仍未能生成,已放弃补推)\n" - if len(body) > 6000: - body = body[:6000] + "\n…(内容过长已截断)" - ok = xmpp_push(body) - print(f"[BACKFILL] 补推{'成功' if ok else '失败'}: {len(ready)} 只", flush=True) + # 2026-08-25 老莫新规则:只推有操作建议信号的,单只标准通道(门禁+12维全文), + # 观望/关注不推XMPP只归档broadcast + _ACTION_SIG = ("买入", "可买入", "可加仓") + pushed = 0 + conn2 = sqlite3.connect(DB, timeout=30) + for code, name, strat, rr, fa in ready: + tsig = conn2.execute( + "SELECT timing_signal FROM holding_strategies WHERE code=? AND status='active'", (code,)).fetchone() + if tsig and any(s in str(tsig[0] or "") for s in _ACTION_SIG): + try: + from mofin_db import push_recommend_alert + if push_recommend_alert(conn2, code): + pushed += 1 + except Exception as e: + print(f" ⚠️ {code} 补推失败: {e}", flush=True) + conn2.close() + print(f"[BACKFILL] 补推完成: {pushed}只有操作建议已推XMPP,其余仅归档broadcast", flush=True) if __name__ == "__main__": wait = int(sys.argv[1]) if len(sys.argv) > 1 else 90