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]}")