From 9e995accb2c63809910413b2e8bf59059fe4eaf3 Mon Sep 17 00:00:00 2001 From: hmo Date: Thu, 23 Jul 2026 14:42:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(template):=20=E7=A9=BA=E4=BB=93=E8=82=A1?= =?UTF-8?q?=E7=A5=A8=E4=B8=8D=E5=86=8D=E6=98=BE=E7=A4=BA'=E7=9B=88?= =?UTF-8?q?=E5=88=A9=E6=8C=81=E6=9C=89'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 技术模板action首段按profit_pct打标签, 非持仓cost=0→profit=0→永远掉进'盈利持有' (601998: 空仓+信号买入+显示'盈利持有', 自相矛盾) - 非持仓(shares=0/is_watchlist): 买入信号→'空仓·可建仓', 其他→'空仓关注' - manual分支同款修复 --- deploy/profile-scripts/strategy_lifecycle.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/deploy/profile-scripts/strategy_lifecycle.py b/deploy/profile-scripts/strategy_lifecycle.py index b0f0867e..0df31036 100644 --- a/deploy/profile-scripts/strategy_lifecycle.py +++ b/deploy/profile-scripts/strategy_lifecycle.py @@ -1452,7 +1452,14 @@ def reassess_strategy(code, name, price, cost, shares, current_action, # ----- 构造 action 描述(供 cron prompt 使用) ----- action_parts = [] - if profit_pct < -20: + # 非持仓(自选股/未持有,shares=0):盈亏标签无意义——cost=0 → profit_pct=0 → + # 永远掉进"盈利持有",空仓股票显示"盈利持有"自相矛盾(2026-07-23 老爸抓包601998) + if not shares or is_watchlist: + if any(s in timing_signal for s in ("买入", "加仓", "可追")): + action_parts.append("空仓·可建仓") + else: + action_parts.append("空仓关注") + elif profit_pct < -20: action_parts.append("深套持有") elif profit_pct < -10: action_parts.append("持有观察") @@ -2173,7 +2180,11 @@ def regenerate_all(stdout=True): # 重建 action 文本(引用手动参数,不引用自动计算的) profit_pct = (price - cost) / cost * 100 if cost else 0 manual_action_parts = [] - if profit_pct < -20: + # 非持仓:同1455行修复,空仓不显示盈亏标签 + if not shares or is_wl: + _ts0 = result.get("timing_signal", "") + manual_action_parts.append("空仓·可建仓" if any(s in _ts0 for s in ("买入","加仓","可追")) else "空仓关注") + elif profit_pct < -20: manual_action_parts.append("深套持有") elif profit_pct < -10: manual_action_parts.append("持有观察")