From a9ba8a27b486900149be3249175a5bd4552d35c7 Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 18 Aug 2026 02:42:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20leader=5Fscanner=E8=A1=A5=E5=86=99candid?= =?UTF-8?q?ates(=E5=B8=A6rr/source=5Fstrategy)+v=5Fnext=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E2=80=94=E2=80=94trend=5Fup=E6=BF=80=E6=B4=BB=E7=AD=96?= =?UTF-8?q?=E7=95=A5(v=5Fnext/v8.1)=E7=9C=9F=E6=AD=A3=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E9=80=89=E8=82=A1=E7=AE=A1=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/leader_scanner.py | 34 +++++++++++++++++++++ deploy/profile-scripts/strategy_executor.py | 1 + 2 files changed, 35 insertions(+) diff --git a/deploy/profile-scripts/leader_scanner.py b/deploy/profile-scripts/leader_scanner.py index 2519b2d6..9c96c0ef 100644 --- a/deploy/profile-scripts/leader_scanner.py +++ b/deploy/profile-scripts/leader_scanner.py @@ -17,6 +17,7 @@ 注意:这是初版框架,需 MoFin 引擎验证达标(年化≥13.2%)才正式上线 """ +import os import sqlite3 import json from datetime import datetime @@ -90,6 +91,39 @@ def scan_leaders(): def main(): signals = scan_leaders() + # 2026-08-18 补写 candidates(trend_up 激活策略真正进入选股管道) + _strategy_tag = os.environ.get("LEADER_STRATEGY", "v_next") + try: + _c = sqlite3.connect(DB, timeout=30) + _c.execute("PRAGMA busy_timeout=30000") + _now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + _ins = 0 + for s in signals: + code = str(s["code"]) + _price = s.get("ma20") or 0 # 用 MA20 附近作为参考价 + if _price <= 0: + continue + _sl = round(_price * 0.92, 2) # 跌破 MA20 容忍 8% + _tp = round(_price * 1.15, 2) # +15% 压力位 + _mid = (_price * 0.98 + _price) / 2 + _rr = round((_tp - _mid) / (_mid - _sl), 2) if _mid > _sl else 0 + _en = f"{_price*0.98:.2f}~{_price:.2f}" + try: + _c.execute( + "INSERT INTO candidates (code, name, sector, reason, entry_range, stop_loss, target, rr, source_strategy, created_at) " + "VALUES (?,?,?,?,?,?,?,?,?,datetime('now','localtime')) " + "ON CONFLICT(code) DO UPDATE SET reason=excluded.reason, entry_range=excluded.entry_range, " + "stop_loss=excluded.stop_loss, target=excluded.target, rr=excluded.rr, source_strategy=excluded.source_strategy", + (code, code, _strategy_tag, + f"龙头回调MA20: rsi={s.get('rsi')} dist={s.get('dist_ma20')}% mcap_q={s.get('mcap_q')}", + _en, _sl, _tp, _rr, _strategy_tag)) + _ins += 1 + except Exception: + pass + _c.commit(); _c.close() + print(f"写入 candidates: {_ins} 只 (策略 {_strategy_tag})") + except Exception as e: + print(f"candidates 写入失败: {e}") out = { "state": load_market_state().get("state", "neutral"), "signals": signals, diff --git a/deploy/profile-scripts/strategy_executor.py b/deploy/profile-scripts/strategy_executor.py index 7dbde476..2e39ca56 100644 --- a/deploy/profile-scripts/strategy_executor.py +++ b/deploy/profile-scripts/strategy_executor.py @@ -51,6 +51,7 @@ STRATEGY_SCANNER = { "v_lurk_v1": "mr_scanner.py", "v_lurk_v2": "mr_scanner.py", "v_lurk_v3": "mr_scanner.py", + "v_next": "leader_scanner.py", "v_next4": "leader_scanner.py", "v8.1": "leader_scanner.py", "v_next5": "leader_scanner.py",