From 9e26a3d226c042b0e0c4096dfebab23941bf541f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Thu, 9 Jul 2026 21:57:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B9=9D=E7=BB=B4=E5=88=86=E6=9E=90?= =?UTF-8?q?=E8=A1=A5=E8=A1=8C=E4=B8=9A+=E6=B6=88=E6=81=AF=E9=9D=A2(signal?= =?UTF-8?q?=5Fnews)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/per_stock_reassess.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/per_stock_reassess.py b/scripts/per_stock_reassess.py index b905e03f..5ae8f7c5 100644 --- a/scripts/per_stock_reassess.py +++ b/scripts/per_stock_reassess.py @@ -144,15 +144,36 @@ def _build_full_analysis(code, entry, result): # 从stock_sectors表补行业 try: _s2 = __import__('sqlite3').connect("/home/hmo/MoFin/data/mofin.db") - _sr = _s2.execute("SELECT sector FROM stock_sectors WHERE code=? LIMIT 1", (code,)).fetchone() + _sr = _s2.execute("SELECT sector_name FROM stock_sectors WHERE code=? LIMIT 1", (code,)).fetchone() if _sr and _sr[0]: lines.append(f"⑦ 行业背景:{_sr[0]}") _s2.close() except: pass + + # 消息面:从signal_news读最新信号 + news_lines = [] + try: + _n_db = __import__('sqlite3').connect("/home/hmo/MoFin/data/mofin.db") + _nr = _n_db.execute( + "SELECT summary, overall_sentiment, created_at FROM signal_news " + "WHERE (sector LIKE ? OR sector LIKE ?) AND overall_sentiment IN ('利好','利空') " + "ORDER BY id DESC LIMIT 2", + (f'%{code}%', f'%{name[:4]}%') + ).fetchall() + for _ns in _nr: + _sent = _ns[1] + _icon = '📈' if '利好' in str(_sent) else '📉' + news_lines.append(f"{_icon} {_ns[0][:60]} ({str(_ns[2])[:10]})") + _n_db.close() + except: + pass if category: lines.append(f"⑧ 分类评级:{category}") lines.append(f"⑨ 策略信号:{signal}") + if news_lines: + lines.append("") + lines.extend(news_lines) if act: lines.append(f"\n策略详情:{act[:200]}")