#!/usr/bin/env python3
"""Deep check 01888 decisions"""
import json, sqlite3

# Check decisions.json directly
with open('/home/hmo/web-dashboard/data/decisions.json') as f:
    raw = json.load(f)

count = 0
for d in raw.get('decisions', []):
    if d.get('code') == '01888':
        count += 1
        print(f"[JSON entry {count}] price={d.get('price')} cost={d.get('cost')} shares={d.get('shares')}")
        print(f"  curr={d.get('currency','none')} status={d.get('status')} type={d.get('type')}")
        print(f"  stop_loss={d.get('stop_loss')} take_profit={d.get('trigger',{}).get('take_profit')}")

print(f"\nTotal 01888 entries in decisions.json: {count}")

# Also check holding_strategies table
db = sqlite3.connect('/home/hmo/web-dashboard/data/mofin.db')
db.row_factory = sqlite3.Row
rows = db.execute("SELECT * FROM holding_strategies WHERE code='01888' ORDER BY updated_at DESC").fetchall()
print(f"\nholding_strategies entries: {len(rows)}")
for r in rows:
    print(f"  cost={r['cost']} price={r['price']} shares={r['shares']} curr={r['currency']} status={r['status']} updated={r['updated_at']}")
db.close()
