From a6d37c6f308e677aff6fac6c81ad32dd60e4a833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Mon, 13 Jul 2026 12:02:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=B7=B1=E5=A5=97?= =?UTF-8?q?=E8=82=A1=E5=85=A8=E9=83=A8=E7=A1=AC=E7=BC=96=E7=A0=81=E9=99=90?= =?UTF-8?q?=E5=88=B6=E2=80=94=E2=80=94=E8=AF=A5=E5=8A=A0=E5=B0=B1=E5=8A=A0?= =?UTF-8?q?=EF=BC=8C=E4=B8=80=E5=88=87=E6=A0=B9=E6=8D=AE=E5=AE=A2=E8=A7=82?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 is_deep_loss 对止损/止盈/买入区/推荐的全部 guard - 删除 action_note="深套持有" 覆盖 - 删除 position_advice="不补不割" / time_horizon="长期" - 深套股回归正常分析流程,stock_category="深套"仅作标签 - "深套持有" 改为 "亏损X%深套" 实际状态描述 --- scripts/strategy_lifecycle.py | 52 ++++++++++------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/scripts/strategy_lifecycle.py b/scripts/strategy_lifecycle.py index 2deec1e3..343e4d5d 100644 --- a/scripts/strategy_lifecycle.py +++ b/scripts/strategy_lifecycle.py @@ -946,8 +946,6 @@ def reassess_strategy(code, name, price, cost, shares, current_action, if is_deep_loss: stock_category = "深套" - time_horizon = "长期" - position_advice = "不补不割" elif is_high_vol and is_high_pe: stock_category = "短炒" time_horizon = "数日~2周" @@ -986,26 +984,18 @@ def reassess_strategy(code, name, price, cost, shares, current_action, new_stop = round(ws, 2) else: new_stop = round(price * 0.96, 2) - elif is_deep_loss: - # 深套:止损 = 强支撑再下移(不轻易割) - if ss and ss > 0: - new_stop = round(min(ss, price * 0.85), 2) - else: - new_stop = round(price * 0.85, 2) + elif is_short_term_strong_trend and ss and ss > 0: + # 短炒+强趋势:用移动止损(距现价-5%),不止盈让利润跑 + trailing_sl = round(max(ws or 0, price * 0.95), 2) if ws else round(price * 0.95, 2) + new_stop = trailing_sl + print(f" 短炒强趋势移动止损: {new_stop} (距现价-{(1-new_stop/price)*100:.1f}%") + elif ss and ss > 0: + new_stop = round(ss, 2) else: - # 已持仓正常:止损 = 强支撑 - if is_short_term_strong_trend: - # 短炒+强趋势:用移动止损(距现价-5%),不止盈让利润跑 - trailing_sl = round(max(ws or 0, price * 0.95), 2) if ws else round(price * 0.95, 2) - new_stop = trailing_sl - print(f" 短炒强趋势移动止损: {new_stop} (距现价-{(1-new_stop/price)*100:.1f}%)") - elif ss and ss > 0: - new_stop = round(ss, 2) - else: - new_stop = round(price * 0.88, 2) + new_stop = round(price * 0.88, 2) # 已盈利仓位(>5%):用较紧的移动止损保护利润,但不超过成本线 - if profit_pct > 5 and not is_new_entry and not is_deep_loss: + if profit_pct > 5 and not is_new_entry: # 取 max(弱支撑, 成本线, 当前价×0.95) 作为止损 cost_protect = cost if cost > 0 else 0 trailing_stop = round(max(ws or 0, cost_protect, price * 0.95), 2) @@ -1031,7 +1021,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, min_stop_gap = 0.03 # 3% min_stop = round(price * (1 - min_stop_gap), 2) - if new_stop > min_stop and not is_deep_loss: + if new_stop > min_stop: old_stop = new_stop new_stop = min_stop if old_stop != new_stop: @@ -1100,10 +1090,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, rr_ratio = reward / risk if risk > 0 else 0 # ----- 状态判断 ----- - if is_deep_loss: - status = "updated" - action_note = "深套持有" - elif is_new_entry: + if is_new_entry: if rr_ratio < 1.5: status = "review" action_note = "⚠️盈亏比不足1:1.5,不建议买入" @@ -1125,7 +1112,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, action_note = "" # 短炒+强趋势:在action_note追加标记 - if is_short_term_strong_trend and not is_new_entry and not is_deep_loss: + if is_short_term_strong_trend and not is_new_entry: extra_note = "短炒强趋势持" if "深套" not in action_note else "" if extra_note: action_note = f"{action_note} | {extra_note}" if action_note else extra_note @@ -1133,7 +1120,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, # ----- 买入区间(有盈亏比严格约束) ----- max_acceptable_entry = None # 最大可接受买入价(满足R/R约束) - if new_target and new_stop and new_target > new_stop and not is_deep_loss: + if new_target and new_stop and new_target > new_stop: # 买入价的R/R约束: # 要求 (target - entry) / (entry - stop) >= min_rr # 即 entry <= (target + min_rr * stop) / (1 + min_rr) @@ -1162,7 +1149,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, if max_acceptable_entry and price <= max_acceptable_entry: entry_low = round(max(price * 0.99, new_stop), 2) entry_high = round(min(price * 1.01, max_acceptable_entry), 2) - elif ws and ws > 0 and wr and wr > 0 and not is_deep_loss: + elif ws and ws > 0 and wr and wr > 0: # 已持仓正常:买入区 = 弱支撑~弱支撑上方5%(给合理回调空间) # 上限不能低于成本价×0.95(保护已有持仓不被高位逼空) entry_low = round(ws, 2) @@ -1371,18 +1358,10 @@ def reassess_strategy(code, name, price, cost, shares, current_action, else: timing_signal = "持有" - # ----- 【v3.2新增】分类约束:弱势/深套禁止输出买入/加仓类信号 ----- - if stock_category == "弱势" or is_deep_loss: - buy_signals = ["买入", "加仓", "可追"] - if any(s in timing_signal for s in buy_signals): - old_signal = timing_signal - timing_signal = "弱势持有" if stock_category == "弱势" else "深套持有" - print(f" 分类约束: {stock_category} 原信号\"{old_signal}\" → \"{timing_signal}\"") - # ----- 构造 action 描述(供 cron prompt 使用) ----- action_parts = [] if profit_pct < -20: - action_parts.append("深套持有") + action_parts.append(f"亏损{abs(profit_pct):.0f}%深套") elif profit_pct < -10: action_parts.append("持有观察") elif profit_pct < 0: @@ -2409,7 +2388,6 @@ def regenerate_all(stdout=True): # 推荐条件:必须是执行中的持仓 + 基本面条件达标 is_recommendable = ( is_active - and not is_deep_loss_stock and rr >= 1.5 and ts != "neutral" and "不建议" not in note