From 7329c651b00046076fd8ac447eff3c616322c194 Mon Sep 17 00:00:00 2001 From: xxm Date: Tue, 18 Aug 2026 10:50:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20B=E5=B1=82=E5=8F=A3=E5=BE=84=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E2=80=94=E2=80=94entry=E5=81=8F=E7=A6=BB=E7=8E=B0?= =?UTF-8?q?=E4=BB=B7>20%=E8=A7=A6=E5=8F=91=E9=87=8D=E8=AF=84=E6=A0=A1?= =?UTF-8?q?=E5=87=86(=E4=B8=8D=E5=86=8D50%=E6=94=BE=E8=A1=8C),=E5=85=88?= =?UTF-8?q?=E6=A0=A1=E5=87=86=E5=90=8E=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/promote_candidates.py | 34 +++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/deploy/profile-scripts/promote_candidates.py b/deploy/profile-scripts/promote_candidates.py index ea9ebba5..a704ae57 100644 --- a/deploy/profile-scripts/promote_candidates.py +++ b/deploy/profile-scripts/promote_candidates.py @@ -143,7 +143,8 @@ def main(): print(f" ⏭ {code} {name} 候选参数无效(区{el}~{eh} 损{sl} 盈{tp}),跳过") processed += 1 continue - # ── B. entry_range 与现价偏离>50% → 不直接用(标记需重评校准,防错误区间进自选)── + # ── B. entry_range 偏离现价>20% → 数据异常,先重评校准(LLM算正确区间)→ 用正确区间入库 ── + _dev = 0 try: import subprocess, json as _jj _r2 = subprocess.run(["python3", "/home/hmo/.hermes/profiles/position-analyst/scripts/stock_quote.py", code], @@ -152,12 +153,35 @@ def main(): _cur_price = float(_q.get("price", 0)) if _cur_price > 0: _dev = abs((_cur_price - (el + eh) / 2) / _cur_price) * 100 - if _dev > 50: - print(f" ⏭ {code} {name} 买入区{el}~{eh} 偏离现价{_cur_price} {_dev:.0f}%(错误区间),标记重评校准不入自选") - processed += 1 - continue except Exception: pass + if _dev > 20.0: + # 数据异常:先重评(LLM算正确区间),成功则用正确区间,失败则跳过 + print(f" ⚠️ {code} {name} 买入区{el}~{eh} 偏离现价{_dev:.0f}%(数据异常),先重评校准...", flush=True) + try: + _r = subprocess.run(["/home/hmo/MoFin/venv/bin/python", + "/home/hmo/MoFin/deploy/profile-scripts/per_stock_reassess.py", code], + capture_output=True, text=True, timeout=REASSESS_TIMEOUT) + if _r.returncode == 0: + # 重评后读 holding 里 LLM 校准的 entry_low/high(batch_reassess A 层已覆盖) + _cur2 = conn.execute( + "SELECT entry_low, entry_high FROM holding_strategies WHERE code=? AND status='active'", + (code,)).fetchone() + if _cur2 and _cur2[0] and _cur2[1]: + el, eh = float(_cur2[0]), float(_cur2[1]) + print(f" ✅ 重评校准后买入区 {el}~{eh}", flush=True) + else: + print(f" ⏭ 重评后无有效买入区,跳过", flush=True) + processed += 1 + continue + else: + print(f" ⏭ 重评失败(区间异常且无法校准),跳过", flush=True) + processed += 1 + continue + except Exception as _e: + print(f" ⏭ 重评异常({_e}),跳过", flush=True) + processed += 1 + continue # ── C. 可执行性检查:止损距离≥2%、止盈空间≥3%、修正风报比(含成本)≥2 ── _price_est = (el + eh) / 2 _stop_dist = (_price_est - sl) / _price_est * 100 if sl > 0 else 0