diff --git a/deploy/profile-scripts/watchlist_auto_exit.py b/deploy/profile-scripts/watchlist_auto_exit.py index 85e537fd..b1bdeec6 100644 --- a/deploy/profile-scripts/watchlist_auto_exit.py +++ b/deploy/profile-scripts/watchlist_auto_exit.py @@ -81,14 +81,20 @@ def main(dry_run=False): ) # 回归选股池(2026-08-03 老莫修正:废除策略后票回归候选池,下次重走完整流程) _stock_name = conn.execute("SELECT name FROM stocks WHERE code=?", (code,)).fetchone() + # 2026-08-17 修复:sector 用该股自己的 strategy_name(保留来源策略语义,不再硬编码 v_mr) + _strat = conn.execute( + "SELECT strategy_name FROM holding_strategies WHERE code=? AND status='active'", + (code,)).fetchone() + _strat_name = (_strat[0] if _strat and _strat[0] else "unknown") conn.execute( - "INSERT INTO candidates (code, name, sector, reason, dropped, drop_reason, promoted, created_at) " - "VALUES (?,?,?,?,0,NULL,0,datetime('now','localtime')) " + "INSERT INTO candidates (code, name, sector, reason, dropped, drop_reason, promoted, " + "source_strategy, created_at) " + "VALUES (?,?,?,?,0,NULL,0,?,datetime('now','localtime')) " "ON CONFLICT(code) DO UPDATE SET " "name=excluded.name, dropped=0, drop_reason=NULL, promoted=0, " - "reason=excluded.reason, created_at=excluded.created_at", - (code, (_stock_name[0] if _stock_name else name) or "", "v_mr", - "自选退出回归选股池: " + reason_text) + "reason=excluded.reason, source_strategy=excluded.source_strategy, created_at=excluded.created_at", + (code, (_stock_name[0] if _stock_name else name) or "", _strat_name, + "自选退出回归选股池: " + reason_text, _strat_name) ) print(f" 🔴 删除: {code} {name or ''} | {reason_text}") else: