feat: 淘汰逻辑修正(仅保留卖出信号+RR<1.0保底)

数据: 死水3连淘汰1126只,淘汰后20日60%误杀(信号不充分3连71%涨), 仅卖出信号正确(-2.2%)
This commit is contained in:
xxm
2026-08-17 19:08:21 +08:00
parent c9a0cc9183
commit 1368b1790c
2 changed files with 66 additions and 28 deletions
+8 -28
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
"""watchlist_auto_exit.py — 自选退出机制
每天盘前执行,扫描自选策略:
- 连续N天信号为"卖出" → 自动退出
- 连续N天评级极低且价格远离买入区 → 自动退出
每天盘前执行,扫描自选策略2026-08-17 数据驱动修正)
- 信号=卖出 → 自动退出(数据验证唯一正确条件:20日后-2.2%
- RR<1.0 → 自动退出(保底:防负期望交易)
- 已废除:死水3连(60%误杀,信号不充分3连71%涨)/ 远离买区 / 零仓位弱信号
- 记录出入日志到 watchlist_log 表
"""
import sqlite3, sys, json
@@ -47,32 +48,11 @@ def main(dry_run=False):
if "卖出" in signal_str:
reasons.append(f"信号={signal_str}")
# 条件2: 信号=观望/信号不充分 且 价格远离买入区
if "观望" in signal_str or "信号不充分" in signal_str:
if price and el and eh and el > 0 and eh > 0:
if price > eh * 1.20: # 高于买入区上沿20%
reasons.append(f"{price}超买区上沿+{((price/eh)-1)*100:.0f}%")
elif el > 0 and price < el * 0.85: # 低于买入区下沿15%
reasons.append(f"{price}低于买区下沿{(1-price/el)*100:.0f}%")
# ── 2026-08-17 淘汰逻辑修正(数据驱动,老莫确认方案A)──
# 数据:死水3连/远离买区/RR<2.0 淘汰后20日 60%误杀(详见 docs/淘汰逻辑验证.md)
# 只保留:信号=卖出(唯一数据支持的正确条件)+ RR<1.0 保底(防负期望交易)
# 条件3: 已清仓/零仓位且信号差
pos_str = str(pos_advice or "")
if rank <= 1 and ("0%" in pos_str or "清仓" in pos_str or "不参与" in pos_str):
reasons.append(f"仓位建议={pos_str}")
# ── 优中选优新增(2026-07-24 老爸)──
# 条件4: 死水闸——最近3次重评信号均为 观望/信号不充分/弱势持有 → 退出
_weak = ("观望", "信号不充分", "弱势持有")
try:
_hist = conn.execute(
"SELECT timing_signal FROM strategy_history WHERE code=? "
"ORDER BY snapshotted_at DESC LIMIT 3", (code,)).fetchall()
if len(_hist) >= 3 and all((h[0] or "") in _weak for h in _hist):
reasons.append(f"死水3连({','.join((h[0] or '?') for h in _hist)}")
except Exception:
pass
# 条件5: RR闸——RR<2.0 淘汰(2026-08-17 老莫:每日重评后低于2.0淘汰,与promote门槛2.0闭环)
# 条件2(保底): RR<1.0 淘汰(止损距离≥止盈距离的负期望交易)
try:
_rr = conn.execute(
"SELECT rr_ratio FROM holding_strategies WHERE code=? AND status='active'",