fix: RR架构统一——s2_panic_v2补rr列(断链)/per_stock_reassess删rr覆盖(RR由scanner定)/strategy_lifecycle不重算rr

This commit is contained in:
xxm
2026-08-18 13:27:45 +08:00
parent 13ff507a3e
commit 0ca4e4b69f
3 changed files with 16 additions and 25 deletions
+4 -12
View File
@@ -66,18 +66,10 @@ def _build_full_analysis(code, entry, result):
eh = result.get("entry_high")
sl = result.get("stop_loss") or entry.get("stop_loss", 0)
tp = result.get("take_profit") or entry.get("take_profit", 0)
# 2026-08-18 修复 rr_ratio:统一用 entry/stop/tp 算(与 promote 同口径 rr = (tp-mid)/(mid-sl)
# strategy_lifecycle 的 rr_ratio 可能算错(6.5 vs 实际 8.64),统一用 entry/stop/tp 算最准
_el_rr = result.get("entry_low") if result.get("entry_low") is not None else entry.get("entry_low", 0)
_eh_rr = result.get("entry_high") if result.get("entry_high") is not None else entry.get("entry_high", 0)
_sl_rr = result.get("stop_loss") or entry.get("stop_loss", 0)
_tp_rr = result.get("take_profit") or entry.get("take_profit", 0)
if _el_rr > 0 and _eh_rr > _el_rr and _sl_rr > 0 and _tp_rr > 0:
_mid_rr = (_el_rr + _eh_rr) / 2
rr = round((_tp_rr - _mid_rr) / (_mid_rr - _sl_rr), 2) if _mid_rr > _sl_rr else 0
else:
# 无有效区间/止损/止盈时,用 holding 的旧 rr_ratio 或 0
rr = entry.get("rr_ratio", 0)
# 2026-08-18 修复:删除 rr_ratio 覆盖——RR 由 scanner 定(candidates.rr=holding.rr_ratio),
# per_stock_reassess 不该重算/覆盖(它该用 holding 的 rr_ratio,不重算)。
# 正确架构:RR 是 scanner 定义的单一事实来源,per_stock_reassess 只读不重算。
rr = entry.get("rr_ratio", 0)
act = result.get("action", "")
# ── 从DB拉取大盘、基本面、资金流 ──