chore: 清理临时文件
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#!/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