diff --git a/deploy/profile-scripts/per_stock_reassess.py b/deploy/profile-scripts/per_stock_reassess.py index ab658215..0cc74115 100644 --- a/deploy/profile-scripts/per_stock_reassess.py +++ b/deploy/profile-scripts/per_stock_reassess.py @@ -470,6 +470,26 @@ def main(): _rc_conn.close() if _sig: print(f" ✅ LLM信号={_sig} 已对齐") + # 2026-08-18 策略判断落库(复用 batch 的 parse_response 从 full_analysis 提取) + try: + from batch_reassess import parse_response as _pr2 + _p2 = _pr2(_full_analysis_text or "") + _j2 = _p2.get("strategy_judge", "") + _st2 = _p2.get("strategy_switch_to", "") + if _j2 == "策略失效重定": + _rc_conn = __import__('sqlite3').connect('/home/hmo/MoFin/data/mofin.db') + _rc_conn.execute("UPDATE holding_strategies SET strategy_state='invalidated' WHERE code=? AND status='active'", (code,)) + _rc_conn.commit(); _rc_conn.close() + print(f" ✅ 策略判断=策略失效重定,strategy_state→invalidated") + elif _j2 == "更换策略归类" and _st2: + _rc_conn = __import__('sqlite3').connect('/home/hmo/MoFin/data/mofin.db') + _rc_conn.execute("UPDATE holding_strategies SET strategy_attributed=?, strategy_state='switched', strategy_provenance='llm_attributed' WHERE code=? AND status='active'", (_st2, code)) + _rc_conn.commit(); _rc_conn.close() + print(f" ✅ 策略判断=更换策略归类,strategy_attributed={_st2}") + elif _j2: + print(f" ℹ️ 策略判断={_j2}(维持/修改参数,不落库)") + except Exception as _pe: + print(f" ⚠️ 策略判断落库失败: {_pe}") # 冷却期已更新(reassessed_at写入) except Exception as _dbe: print(f" [DB FAIL] holding_strategies 写入失败: {_dbe}", file=sys.stderr)