#!/usr/bin/env python3
"""Verify 01888 data after fix"""
import sys
sys.path.insert(0, '/home/hmo/MoFin')
from mo_data import read_portfolio, read_decisions
import sqlite3

# Check DB
db = sqlite3.connect('/home/hmo/web-dashboard/data/mofin.db')
r = db.execute("SELECT code, name, cost, shares, currency FROM holdings WHERE code='01888'").fetchone()
if r:
    print(f"[DB] {r[0]} {r[1]}: cost={r[2]} shares={r[3]} curr={r[4]}")

# Check decisions
dec = read_decisions()
for d in dec.get('decisions', []):
    if d.get('code') == '01888':
        print(f"[DEC] price={d.get('price')} cost={d.get('cost')} shares={d.get('shares')}")
        print(f"      curr={d.get('currency')} status={d.get('status')}")
        c = d.get('cost', 0)
        p = d.get('price', 0)
        if c > 0 and p > 0:
            print(f"      PnL={(p-c)/c*100:.1f}%")

# Check portfolio
pf = read_portfolio()
for h in pf.get('holdings', []):
    if h.get('code') == '01888':
        print(f"[PF] {h.get('code')} cost={h.get('cost')} price={h.get('price')} shares={h.get('shares')}")

db.close()
