fix: B层口径修正——entry偏离现价>20%触发重评校准(不再50%放行),先校准后入库
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user