fix: 删除深套股全部硬编码限制——该加就加,一切根据客观判断

- 删除 is_deep_loss 对止损/止盈/买入区/推荐的全部 guard
- 删除 action_note="深套持有" 覆盖
- 删除 position_advice="不补不割" / time_horizon="长期"
- 深套股回归正常分析流程,stock_category="深套"仅作标签
- "深套持有" 改为 "亏损X%深套" 实际状态描述
This commit is contained in:
知微
2026-07-13 12:02:06 +08:00
parent be961c6af6
commit a6d37c6f30
+15 -37
View File
@@ -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