fix(template): 空仓股票不再显示'盈利持有'
- 技术模板action首段按profit_pct打标签, 非持仓cost=0→profit=0→永远掉进'盈利持有' (601998: 空仓+信号买入+显示'盈利持有', 自相矛盾) - 非持仓(shares=0/is_watchlist): 买入信号→'空仓·可建仓', 其他→'空仓关注' - manual分支同款修复
This commit is contained in:
@@ -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("持有观察")
|
||||
|
||||
Reference in New Issue
Block a user