feat: RR按最近上方阻力结算(老爸:前高挡中间时止盈是放空炮)
- 上方目标=min(止盈, 20日新高若高于基准价) - 601988案例: 止盈6.3但前高6.11挡中间, RR从3.44(虚)→1.33(实) - 突破形态(现价已在20日新高)不惩罚,用止盈全值 - 三值RR同步体现入场价敏感度
This commit is contained in:
+21
-3
@@ -1154,8 +1154,11 @@ def reconcile_signal_from_analysis(conn, code: str) -> str:
|
||||
def recompute_rr(conn, code: str) -> float:
|
||||
"""用买入区+已存止损/止盈重算三值 RR 并写回(rr_low/rr_ratio中值/rr_high)。
|
||||
根治"LLM 不输出 RR → rr_ratio 永远 0"的断链(红线:RR 由系统算,不信 LLM)。
|
||||
公式: RR(x) = (止盈 - x) / (x - 止损);x 分别取买入区下沿/中值/上沿。
|
||||
rr_ratio=中值 RR 用于排序与1.5门槛;rr_low/rr_high 展示入场价敏感度。
|
||||
公式: RR(x) = (上方目标 - x) / (x - 止损);x 分别取买入区下沿/中值/上沿。
|
||||
上方目标 = min(止盈, 20日新高若高于x)(2026-07-24 老爸:
|
||||
前高挡在中间时止盈是放空炮,真实RR必须对最近上方阻力先结算;
|
||||
突破形态(现价已在20日新高)不惩罚,用止盈全值)。
|
||||
rr_ratio=中值 RR 用于排序与2.0门槛;rr_low/rr_high 展示入场价敏感度。
|
||||
区间缺失 → 中值兜底现价(low/high=0);损/盈缺失或 x<=止损 → 该值=0。"""
|
||||
try:
|
||||
row = conn.execute(
|
||||
@@ -1165,9 +1168,24 @@ def recompute_rr(conn, code: str) -> float:
|
||||
return 0.0
|
||||
el, eh, sl, tp = (row[0] or 0), (row[1] or 0), (row[2] or 0), (row[3] or 0)
|
||||
|
||||
# 20日新高(前高阻力)
|
||||
high_20d = 0.0
|
||||
try:
|
||||
r20 = conn.execute(
|
||||
"SELECT MAX(high) FROM (SELECT high FROM stock_daily WHERE code=? ORDER BY date DESC LIMIT 20)",
|
||||
(code,)).fetchone()
|
||||
if r20 and r20[0]:
|
||||
high_20d = float(r20[0])
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _rr(x):
|
||||
if sl > 0 and tp > 0 and x > sl:
|
||||
v = round((tp - x) / (x - sl), 2)
|
||||
# 上方目标:止盈与前高取近者(前高高于x才算阻力,否则视为突破用止盈)
|
||||
target = tp
|
||||
if high_20d > x and high_20d < target:
|
||||
target = high_20d
|
||||
v = round((target - x) / (x - sl), 2)
|
||||
return v if v > 0 else 0.0
|
||||
return 0.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user