diff --git a/scripts/strategy_review.py b/scripts/strategy_review.py index a959512..b19b56f 100644 --- a/scripts/strategy_review.py +++ b/scripts/strategy_review.py @@ -131,19 +131,37 @@ def evaluate_strategy(s, price): exec_verdict = "待定" exec_fail = None + # 取近期最高价(判断是否卖飞,只对有TP的策略拉数据) + recent_high = 0 + if tp > 0: + try: + prefix = "sh" if code.startswith(('60','68','51','56','50')) else "sz" if code.startswith(('00','30','15')) else "hk" + url = f"http://ifzq.gtimg.cn/appstock/app/fqkline/get?param={prefix}{code},day,,,60,qfq" + import subprocess as sp + r = sp.run(["curl", "-s", "--max-time", "3", url], capture_output=True, text=True, timeout=5) + if r.returncode == 0 and r.stdout: + data = json.loads(r.stdout) + day_key = 'qfqday' if prefix != 'hk' else 'day' + bars = data.get('data', {}).get(f'{prefix}{code}', {}).get(day_key, []) + if bars: + recent_high = max(float(b[2]) for b in bars if len(b) > 2) + except: + pass + if sl > 0 and price <= sl: - # 止损触发 → 检查是否过紧 if price >= sl * 0.95: exec_verdict = "存疑(临界触发)" exec_fail = "stop_too_tight" else: exec_verdict = "已触发" - elif tp > 0 and price >= tp: - # 止盈触发 → 检查是否过近 - if price <= tp * 1.05: + elif tp > 0 and (price >= tp or recent_high >= tp): + # 止盈触发或曾触发过 + max_price = max(price, recent_high) + if max_price <= tp * 1.05: exec_verdict = "已触发" else: - exec_verdict = "存疑(突破后继续涨)" + overshoot = (max_price - tp) / tp * 100 + exec_verdict = f"卖飞({overshoot:.0f}%)" exec_fail = "tp_too_close" elif days > 45 and tp > 0 and price < entry_low: exec_verdict = "存疑(久未达标)"