diff --git a/deploy/profile-scripts/price_monitor.py b/deploy/profile-scripts/price_monitor.py index 36a0f241..21b2a94d 100644 --- a/deploy/profile-scripts/price_monitor.py +++ b/deploy/profile-scripts/price_monitor.py @@ -131,6 +131,10 @@ try: capture_output=True, text=True, timeout=180 ) _mark_reassess(code) + # 2026-08-24 防鬼消息:子进程失败不得继续读旧策略冒充"重评结论" + if _r.returncode != 0: + print(f" ⚠️ {code} 12维重评子进程失败(rc={_r.returncode}): {(_r.stderr or _r.stdout or '')[-300:]}", file=sys.stderr, flush=True) + return None except Exception as e: print(f" ⚠️ {code} 12维重评异常: {e}", file=sys.stderr) return None @@ -140,9 +144,17 @@ try: _c = _sq.connect("/home/hmo/MoFin/data/mofin.db", timeout=30) _c.row_factory = _sq.Row _row = _c.execute( - "SELECT timing_signal, action, stop_loss, take_profit, entry_low, entry_high, rr_ratio " + "SELECT timing_signal, action, stop_loss, take_profit, entry_low, entry_high, rr_ratio, reassessed_at " "FROM holding_strategies WHERE code=? AND status='active'", (code,)).fetchone() _c.close() + # 2026-08-24 防鬼消息:rc=0但LLM失败时策略未刷新(reassessed_at不变), + # 旧策略不得冒充"重评结论"——reassessed_at 超过10分钟视为重评未生效 + if _row: + from datetime import datetime as _dt + _ra = _row["reassessed_at"] + if not _ra or (_dt.now() - _dt.fromisoformat(str(_ra))).total_seconds() > 600: + print(f" ⚠️ {code} 重评后策略未刷新(reassessed_at={_ra}),按重评失败处理", file=sys.stderr, flush=True) + return None if _row: return { "timing_signal": _row["timing_signal"] or "", @@ -764,6 +776,12 @@ def run_once(round_label=""): else: _zone_entries.append(f"{name}({code}) {price}→入区+重评{timing_signal}|RR={rr}") outputs.append(f" 📨 止损重评→{timing_signal}: {str(action)[:120]}") + else: + # 2026-08-24:重评未生效(冷却/子进程失败)→发原始告警+人工核查标注, + # 绝不拿旧策略冒充"重评结论"(02202卖出/深套持有鬼消息教训) + if _can_push(code, "stop_loss"): + _push_action("止损告警", f"⚠️ {name}({code}) {price} → 跌破止损{hi}!(12维重评未生效,暂无最新结论,请人工核查)") + outputs.append(f" ⚠️ {code} 重评未生效,已发原始止损告警") except Exception as e: outputs.append(f" ⚠️ 止损重评失败: {e}") try: @@ -949,8 +967,11 @@ def run_once(round_label=""): # 调用技术面驱动重评(非机械百分比) result = _do_llm_reassess(code, name, price, cost, shares, d.get("action", "")) - outputs.append(f" 📊 新策略: 损{result['stop_loss']} 盈{result['take_profit']} 区{result['entry_low']}~{result['entry_high']} RR={result['rr_ratio']}") - reassesed_codes.append(code) + if result: + outputs.append(f" 📊 新策略: 损{result['stop_loss']} 盈{result['take_profit']} 区{result['entry_low']}~{result['entry_high']} RR={result['rr_ratio']}") + reassesed_codes.append(code) + else: + outputs.append(f" ⏭ {code} 重评未生效(冷却/子进程失败),沿用现有策略") except Exception as e: outputs.append(f" ⚠️ 重评失败: {e}") diff --git a/deploy/profile-scripts/strategy_lifecycle.py b/deploy/profile-scripts/strategy_lifecycle.py index af0d0d07..7a63297f 100644 --- a/deploy/profile-scripts/strategy_lifecycle.py +++ b/deploy/profile-scripts/strategy_lifecycle.py @@ -939,18 +939,18 @@ def reassess_strategy(code, name, price, cost, shares, current_action, # ----- 筹码分布支撑/阻力(中长线参考,加情景权重) ----- chip_sr = None chip_weight = 0.5 # 默认中等权重 - regime = detect_scenario() - regime_id = regime.get("id", "weak_consolidation") - - # 情景决定筹码因子权重 - if regime_id == "weak_consolidation": + # 2026-08-24 修复:detect_scenario(四态已废弃,8/20漏改此处)→ load_market_regime(三态) + # 映射:choppy≈weak_consolidation trend_up≈bullish_recovery trend_down≈sharp_decline + _mr_row = load_market_regime() + regime_id = (_mr_row or {}).get("regime", "choppy") + + # 温区决定筹码因子权重 + if regime_id == "choppy": chip_weight = 0.9 # 震荡市筹码最准 - elif regime_id == "bullish_recovery": + elif regime_id == "trend_up": chip_weight = 0.4 # 上涨趋势筹码阻力可能被突破 - elif regime_id == "sharp_decline": - chip_weight = 0.2 # 急跌中筹码支撑可能失效 - elif regime_id == "sector_rotation": - chip_weight = 0.6 # 轮动市中筹码有一定参考 + elif regime_id == "trend_down": + chip_weight = 0.2 # 下跌中筹码支撑可能失效 try: chip_sr = calc_chip_sr(code, price)