refactor: 统一价格入口 mo_data.get_price() - 22个脚本移除自拉腾讯API
所有价格获取统一走 mo_data.get_price() / get_prices_batch():
- 优先读 live_prices(DB) → 无/过期才调 stock_quote(API) → 自动写回DB
- 22个脚本全部替换:branch_scanner chip_factors divergence_detector
market_screener mo_provider mofin_collect monitor_300308 300308_monitor
multi_timeframe refresh_macro_context stale_detector stale_push_wlin
stock_profile strategy_evaluator strategy_lifecycle strategy_review
strategy-staleness-check technical_analysis xiaoguo_signal_consumer
collect_evaluation_data
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""sync_db_to_json.py — 将DB数据同步回JSON文件(反向同步)
|
||||
|
||||
DB是权威源,JSON文件是只读的兼容层。
|
||||
每15分钟将DB中的决策数据写到decisions.json。
|
||||
"""
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
sys.path.insert(0, "/home/hmo/MoFin")
|
||||
|
||||
DECISIONS_PATH = "/home/hmo/web-dashboard/data/decisions.json"
|
||||
|
||||
try:
|
||||
from mo_data import read_decisions, read_portfolio, read_watchlist
|
||||
decisions = read_decisions()
|
||||
portfolio = read_portfolio()
|
||||
watchlist = read_watchlist()
|
||||
|
||||
with open(DECISIONS_PATH, "w") as f:
|
||||
json.dump(decisions, f, ensure_ascii=False, indent=2)
|
||||
|
||||
cnt = len(decisions.get("decisions", []))
|
||||
print(f"[SILENT] decisions.json updated: {cnt} entries from DB")
|
||||
except Exception as e:
|
||||
print(f"[SILENT] sync failed: {e}")
|
||||
Reference in New Issue
Block a user