数据新鲜度防御体系(致命错误防御)
根因:今下午报告用周五多周期缓存(multi_tf_cache)作周一操作建议, 中芯国际H浮盈+10%被错报破止损。 修改: 1. price_monitor 新增 live_prices.json 写入(每2分钟刷新所有实时价) 2. 新增 data_freshness.py — data_freshness check function 3. intraday_health_check price_monitor检测从10min收紧到5min 4. 新增 midday MTF cache refresh (11:00+14:00) 5. cron-report-format pre-flight checklist 新增数据新鲜度检查项 所有报告产出前必须先跑 data_freshness,过期则禁止出操作建议
This commit is contained in:
@@ -135,6 +135,17 @@ def refresh_data_prices():
|
||||
prices = fetch_all_prices(list(all_codes))
|
||||
updated = 0
|
||||
|
||||
# 保存全量实时价快照(供报告管道消费,确保分析用最新数据)
|
||||
try:
|
||||
live = {"updated_at": datetime.now().isoformat(), "prices": {}}
|
||||
for code in all_codes:
|
||||
if code in prices:
|
||||
p, c, chg = prices[code]
|
||||
live["prices"][code] = {"price": p, "change_pct": chg}
|
||||
json.dump(live, open("/home/hmo/web-dashboard/data/live_prices.json", "w"), indent=2)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 更新portfolio(只在价格变化时写入,避免触发文件变更通知)
|
||||
changed = False
|
||||
for s in pf.get('holdings', []):
|
||||
|
||||
Reference in New Issue
Block a user