From f1d3862480486271a93f29c097ecb36c1da45d6f Mon Sep 17 00:00:00 2001 From: xxm Date: Thu, 20 Aug 2026 16:00:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(prompt):=20=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=AD=E8=A3=82=E2=80=94=E2=80=94=E8=A1=8C=E4=B8=9A?= =?UTF-8?q?=E5=BC=BA=E5=BA=A6=E8=BF=9BLLM+=E7=A7=BB=E9=99=A4=E6=AD=BB?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - collect_data(): 从sector_snapshots读取行业涨跌/排名 - build_prompt(): 注入行业强度数据(行业涨跌%+排名) - 移除current_regime_strategies死数据(旧策略名不匹配strategy_defs) - 港股缺资金流(数据采集层限制,非代码问题) --- deploy/profile-scripts/batch_reassess.py | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/deploy/profile-scripts/batch_reassess.py b/deploy/profile-scripts/batch_reassess.py index bbc0d0ef..16595a08 100644 --- a/deploy/profile-scripts/batch_reassess.py +++ b/deploy/profile-scripts/batch_reassess.py @@ -178,6 +178,22 @@ def collect_data(code): _db2.close() except Exception: pass + + # 行业强度(sector_snapshots: market_watch.py 写入的板块涨跌排名) + try: + _db3 = sqlite3.connect(DB, timeout=30) + _sector = data.get("sector_context", "") + if _sector: + _ss = _db3.execute( + "SELECT change_pct, rank_in_market FROM sector_snapshots " + "WHERE sector_name LIKE ? ORDER BY date DESC LIMIT 1", + (f"%{_sector}%",)).fetchone() + if _ss: + data["sector_change_pct"] = _ss[0] if _ss[0] is not None else None + data["sector_rank"] = _ss[1] if _ss[1] is not None else None + _db3.close() + except Exception: + pass # 情势体检:温区 + 高风险消息 + 执行红线 _sit = {"regime_a": "unknown", "regime_7d_ago": "unknown", "high_risk": "", "breach_stop": "否", "reach_tp": "否", "out_zone": "否", "over_hold": "否"} @@ -229,23 +245,7 @@ def collect_data(code): "status": _pm[6], "retired_reason": _pm[7], "superseded_by": _pm[8], "regime": _pm[9], } data["pos_mgmt_triggered"] = True - # 当前温区合格策略 - try: - import os as _os - import json as _json2 - _wf = "/home/hmo/MoFin/data/strategy_weights.json" - if _os.path.exists(_wf): - _wdata = _json2.load(open(_wf, encoding="utf-8")) - _ra = _wdata.get("regime_active", {}) - _cur_rg = data.get("situation", {}).get("regime_a", "unknown") - data["current_regime_strategies"] = _ra.get(_cur_rg, []) - data["current_regime"] = _cur_rg - else: - data["current_regime_strategies"] = [] - data["current_regime"] = data.get("situation", {}).get("regime_a", "unknown") - except Exception: - data["current_regime_strategies"] = [] - data["current_regime"] = data.get("situation", {}).get("regime_a", "unknown") + # current_regime_strategies 已移除(旧策略名与strategy_defs不匹配) except Exception: pass conn.close() @@ -632,7 +632,7 @@ accumulation(主力建仓) / b_td1_v3(超跌原池优选) / v_mr(弱市深超跌 大盘:{data.get('macro','震荡')}{_macro_label} 最新价:{data.get('price',0)} 涨跌:{data.get('change_pct','0')}%{_price_label} PE={data.get('pe','?')}(最新财报) 市值={data.get('mcap','?')}亿 -行业:{data.get('sector_context','?')}(近一个交易日) +行业:{data.get('sector_context','?')}(近一个交易日){(' 涨跌='+str(data.get('sector_change_pct',''))+'% 排名='+str(data.get('sector_rank',''))) if data.get('sector_change_pct') is not None else ''}{_sector_extra} 技术面:{data.get('tech_snapshot','')[:300]}(MA=5/10/20/60日 支撑阻力=近20日 量价=当日+近5日趋势) {_tech_str} {_tech_str}