From f05f80f2845c6a87da181ad4026c96c73b3fc723 Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 18 Aug 2026 10:20:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20watchlist=E5=9B=9E=E6=B3=A8unknown?= =?UTF-8?q?=E6=97=B6=E7=94=A8=E6=97=A7candidates.sector=20fallback?= =?UTF-8?q?=E2=80=94=E2=80=94=E4=B8=8D=E5=86=8D=E4=BA=A7=E7=94=9Funknown?= =?UTF-8?q?=E6=9D=A5=E6=BA=90=E5=80=99=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/watchlist_auto_exit.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deploy/profile-scripts/watchlist_auto_exit.py b/deploy/profile-scripts/watchlist_auto_exit.py index b1bdeec6..88ea4468 100644 --- a/deploy/profile-scripts/watchlist_auto_exit.py +++ b/deploy/profile-scripts/watchlist_auto_exit.py @@ -86,6 +86,14 @@ def main(dry_run=False): "SELECT strategy_name FROM holding_strategies WHERE code=? AND status='active'", (code,)).fetchone() _strat_name = (_strat[0] if _strat and _strat[0] else "unknown") + # 2026-08-18 修复:holding.strategy_name 为 unknown 时,回退用 candidates 里旧的 sector + # (候选的 sector 是正确策略标签,但 holding 早期 promote 时 source_strategy 可能没继承) + if _strat_name == "unknown" or not _strat_name: + _old_sec = conn.execute( + "SELECT sector FROM candidates WHERE code=?", (code,)).fetchone() + _old_sec_v = str(_old_sec[0]).strip() if _old_sec and _old_sec[0] else "" + if _old_sec_v and _old_sec_v != "unknown": + _strat_name = _old_sec_v conn.execute( "INSERT INTO candidates (code, name, sector, reason, dropped, drop_reason, promoted, " "source_strategy, created_at) "