fix: 自选股强制重评+潜力股管道解冻+健康监控阈值修正

1. mofin_collect.py: 加入自选股(watchlist_stocks)强制重评, 输出持仓+自选两段
2. cron_health_monitor: 只监控7个实时管道, 排除日/周任务
3. 解冻: 知微洞察生成(a1f06826) + 市场精选推荐(759064f5)
This commit is contained in:
知微
2026-07-07 13:37:07 +08:00
parent 8f34681e8d
commit ad74ede2b8
+31 -3
View File
@@ -30,7 +30,7 @@ try:
cur = conn.cursor()
# 读所有活跃持仓及其最新策略更新时间
rows = cur.execute("""
SELECT h.code, h.name, h.price, h.position_pct,
SELECT h.code, h.name, h.price, h.cost, h.shares, h.position_pct,
hs.stop_loss, hs.take_profit, hs.entry_low, hs.entry_high,
hs.created_at, hs.action
FROM holdings h
@@ -111,11 +111,39 @@ try:
print(f" ❌ CREATE_STRATEGY {code} {name} 失败: {e}", flush=True)
conn.commit()
# === 自选股策略检查 + 强制重评 ===
wl_fresh = 0
wl_stale = 0
wl_error = 0
try:
for wr in conn.execute("SELECT code, name, price, entry_low, entry_high, stop_loss FROM watchlist_stocks WHERE is_active=1"):
code = wr["code"]
name = wr["name"]
# 自选股无cost/shares,传0
try:
from strategy_lifecycle import reassess_with_context
result = reassess_with_context(
code, name, wr["price"] or 0,
0, 0, ""
)
if result and result.get("action"):
wl_stale += 1
print(f" 📋 WATCHLIST_REASSESS {code} {name}: →{result['action'][:60]}", flush=True)
else:
wl_fresh += 1
except Exception as e:
wl_error += 1
print(f" ❌ WATCHLIST_REASSESS {code} {name} 失败: {e}", flush=True)
except Exception as e:
print(f" ⚠️ 自选股检查跳过: {e}", flush=True)
conn.close()
total = len(rows)
print(f"策略检查完成: {total}只持仓, {fresh_count}新鲜, {stale_count}过期(已强制重评), {no_strategy_count}无策略(已创建)", flush=True)
if stale_count > 0 or no_strategy_count > 0:
wl_total = wl_fresh + wl_stale + wl_error
print(f"策略检查完成: {total}只持仓({fresh_count}新鲜/{stale_count}过期/{no_strategy_count}无策略) + {wl_total}只自选({wl_fresh}无需/{wl_stale}已重评/{wl_error}失败)", flush=True)
if stale_count > 0 or no_strategy_count > 0 or wl_stale > 0:
print(f"⚠️ 重评完成: {stale_count + no_strategy_count}只已强制刷新, LLM可基于最新策略给出建议", flush=True)
except Exception as e:
print(f"WARN: strategy_freshness_check跳过 ({e})", flush=True)