38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Final verification: full data cycle after JSON→DB migration"""
|
|
import sys
|
|
sys.path.insert(0, '/home/hmo/MoFin')
|
|
|
|
from mo_data import read_portfolio, read_decisions, read_watchlist
|
|
|
|
pf = read_portfolio()
|
|
dec = read_decisions()
|
|
wl = read_watchlist()
|
|
|
|
h = len(pf.get('holdings', []))
|
|
d = len(dec.get('decisions', []))
|
|
w = len(wl.get('stocks', []))
|
|
|
|
print(f"portfolio holdings: {h}")
|
|
print(f"decisions: {d}")
|
|
print(f"watchlist: {w}")
|
|
|
|
# Check one HK stock has correct CNY cost
|
|
for holding in pf.get('holdings', []):
|
|
if holding.get('code') == '01888':
|
|
print(f"\n01888 cost={holding.get('cost')} price={holding.get('price')} curr={holding.get('currency')}")
|
|
c = holding.get('cost', 0); p = holding.get('price', 0)
|
|
if c and p:
|
|
print(f"P&L: {(p-c)/c*100:.1f}%")
|
|
|
|
# Check decisions have currency=CNY
|
|
cnys = sum(1 for d in dec.get('decisions', []) if d.get('currency') == 'CNY')
|
|
print(f"\ndecisions with CNY: {cnys}/{d}")
|
|
|
|
# Check no JSON fallback in mo_data (pure DB)
|
|
with open('/home/hmo/MoFin/mo_data.py') as f:
|
|
content = f.read()
|
|
pure_db = 'json.load(open' not in content
|
|
print(f"mo_data pure DB: {'YES' if pure_db else 'NO — still has JSON'}")
|
|
|
|
print(f"\n{'ALL GOOD' if h and d and w else 'FAIL'}")
|