feat: mo_data.py unified read layer (DB-first, JSON fallback) + cash_log table + batch JSON→DB migration (16 files)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
import json, sys
|
||||
from datetime import datetime, timezone
|
||||
from mo_data import read_portfolio, read_decisions, read_watchlist
|
||||
|
||||
DATA_DIR = "/home/hmo/web-dashboard/data"
|
||||
PORTFOLIO_PATH = f"{DATA_DIR}/portfolio.json"
|
||||
@@ -22,7 +23,7 @@ issues = []
|
||||
|
||||
# ── 1. 总资产校验 ────────────────────────────────────────────
|
||||
try:
|
||||
pf = json.load(open(PORTFOLIO_PATH))
|
||||
pf = mo_data.read_portfolio()
|
||||
mv_calc = sum(h["shares"] * h["price"] for h in pf.get("holdings", []) if h.get("price"))
|
||||
stored_ta = pf.get("total_assets", 0)
|
||||
cash = pf.get("cash", 0)
|
||||
@@ -35,7 +36,7 @@ except Exception as e:
|
||||
|
||||
# ── 2. 持仓 vs 决策交叉检查 ──────────────────────────────────
|
||||
try:
|
||||
dec = json.load(open(DECISIONS_PATH))
|
||||
dec = mo_data.read_decisions()
|
||||
dec_codes = {}
|
||||
for d in dec.get("decisions", []):
|
||||
dec_codes[d["code"]] = d
|
||||
|
||||
Reference in New Issue
Block a user