Gap (reported by user via zhiwei): premarket full review updated technical
params but full_analysis (12-dim LLM matrix) was empty for new holdings
and stale for old ones — batch_reassess existed but was never wired into
the daily pipeline and only covered watchlist.
System fix:
- premarket_full_review.py: new Step 1.5 runs batch_reassess --type
holding --today every trading day 08:10 (force-refresh today's analysis,
timeout 3600s, result in summary.json)
- batch_reassess.py:
- coverage: --type holding|watchlist|all (was watchlist-only)
- staleness: analysis >20h stale gets refreshed (was: skip if any
analysis exists = forever stale)
- --today flag: force re-analyze if not reassessed since 04:00 today
- cash/total read live from portfolio_summary (was hardcoded 321271/
952879 from weeks ago)
- HK stock prefix fix (5-digit codes -> hk, was sending sz00700)
- watchlist_12d_backfill.py: wrapper for hermes cron (no args support)
- cron job '批量补全九维分析-一次性' -> '自选12维分析补全-每日午间'
(daily 12:30 weekdays, covers 109 watchlist stocks missing analysis)
Verified: 300308 got 1920-char 12-dim analysis written to DB at 08:41,
signal=观望, stop/take-profit updated.
65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
||
"""premarket_full_review.py — 盘前全量重评
|
||
|
||
执行顺序:
|
||
1. regenerate_all() 全量技术参数重评(持仓+自选)
|
||
2. batch_reassess.py --type holding --today 持仓12维LLM分析(每日强制刷新)
|
||
3. watchlist_auto_exit() 自选退出检查
|
||
4. 输出摘要
|
||
|
||
调度:交易日 08:10(A股09:30开盘)
|
||
"""
|
||
import sys, os, json
|
||
sys.path.insert(0, '/home/hmo/MoFin')
|
||
|
||
# Step 1: 全量技术参数重评
|
||
print("=" * 50)
|
||
print("📊 盘前全量重评开始")
|
||
print("=" * 50)
|
||
from strategy_lifecycle import regenerate_all
|
||
result = regenerate_all(stdout=True)
|
||
print(f"\n重评完成: {result.get('ok',0)}/{result.get('total',0)}成功")
|
||
|
||
# Step 1.5: 持仓 12 维 LLM 深度分析(每日强制,14只约8-10分钟)
|
||
print("\n" + "=" * 50)
|
||
print("🧠 持仓12维LLM分析(每日强制刷新)")
|
||
print("=" * 50)
|
||
import subprocess as _sp
|
||
analysis_result = {"ok": 0, "fail": 0, "skip": 0}
|
||
try:
|
||
r = _sp.run(
|
||
["python3", "/home/hmo/.hermes/profiles/position-analyst/scripts/batch_reassess.py",
|
||
"--type", "holding", "--today"],
|
||
capture_output=True, text=True, timeout=3600)
|
||
print(r.stdout[-2000:] if len(r.stdout) > 2000 else r.stdout)
|
||
if r.returncode != 0 and r.stderr:
|
||
print(f"⚠️ stderr: {r.stderr[:300]}")
|
||
# 从输出尾部解析统计
|
||
import re as _re
|
||
m = _re.search(r"完成: (\d+)成功, (\d+)失败, (\d+)跳过", r.stdout)
|
||
if m:
|
||
analysis_result = {"ok": int(m.group(1)), "fail": int(m.group(2)), "skip": int(m.group(3))}
|
||
except Exception as e:
|
||
print(f"⚠️ 12维分析步骤异常: {e}")
|
||
|
||
# Step 2: 自选退出
|
||
print("\n" + "=" * 50)
|
||
print("🔍 自选退出检查")
|
||
print("=" * 50)
|
||
from scripts.watchlist_auto_exit import main as auto_exit
|
||
exited = auto_exit(dry_run=False)
|
||
|
||
# Step 3: 写入摘要供开盘简报引用
|
||
summary = {
|
||
"premarket_at": __import__('datetime').datetime.now().isoformat(),
|
||
"reassess": result,
|
||
"llm_analysis_12d": analysis_result,
|
||
"auto_exit": [{"code": c, "name": n, "reason": r} for c, n, s, r in exited],
|
||
"total_kept": result.get('total', 0) - len(exited),
|
||
}
|
||
os.makedirs("/tmp/mofin_premarket", exist_ok=True)
|
||
with open("/tmp/mofin_premarket/summary.json", "w") as f:
|
||
json.dump(summary, f, ensure_ascii=False, indent=2)
|
||
|
||
print(f"\n✅ 盘前重评完毕")
|