From df4ea2faaccb86f697c5cdbe05803aab0d2fee9c Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 18 Aug 2026 15:38:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20strategy=5Flifecycle=20RR=E7=94=A8new=5F?= =?UTF-8?q?stop/new=5Ftarget/price=E7=AE=97(=E4=BF=AENameError=20result?= =?UTF-8?q?=E6=9C=AA=E5=AE=9A=E4=B9=89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/strategy_lifecycle.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/deploy/profile-scripts/strategy_lifecycle.py b/deploy/profile-scripts/strategy_lifecycle.py index 4237f5e4..92a34bc0 100644 --- a/deploy/profile-scripts/strategy_lifecycle.py +++ b/deploy/profile-scripts/strategy_lifecycle.py @@ -1179,11 +1179,14 @@ def reassess_strategy(code, name, price, cost, shares, current_action, found = True break - # ----- 风险回报比(不重算,RR 由 scanner 定)----- - # 2026-08-18 修复:RR 由 scanner 定(candidates.rr=holding.rr_ratio), - # strategy_lifecycle 管持仓状态(信号/止损移动),不重算/重写 RR。 - # 正确架构:RR 是 scanner 定义的单一事实来源,lifecycle 只读不重算。 - rr_ratio = result.get("rr_ratio") or 0 + # ----- 风险回报比(供状态判断,不写回 holding)----- + # 2026-08-18 修复:RR 用局部变量 new_stop/new_target/price 算(result 未定义→NameError)。 + # 供状态判断(is_new_entry+rr<1.5 → 不建议买入);不重锚定 stop/tp 写回 holding + # (RR 由 scanner 定,per_stock_reassess 用 holding 的 rr_ratio)。 + _entry_ref = price + _risk_r = max(_entry_ref - new_stop, _entry_ref * 0.01) + _reward_r = max(new_target - _entry_ref, 0) + rr_ratio = _reward_r / _risk_r if _risk_r > 0 else 0 # ----- 状态判断 ----- if is_deep_loss: