import json
from pathlib import Path

p = Path(r"C:\Users\Administrator\OneDrive\fx_macro_intraday\data\logs\trade_history_eurusd.json")
trades = json.loads(p.read_text(encoding="utf-8"))

print(f"Total EU trades in JSON: {len(trades)}")
print("=" * 70)
total = 0.0
for x in trades:
    total += x.get("net_pnl", 0)
    print(f"  ticket={x['ticket']}  pnl={x['net_pnl']:>10}  "
          f"dir={'LONG' if x['direction']==1 else 'SHORT'}  "
          f"closed={x['closed_at'][:16]}")
print("=" * 70)
print(f"Sum of net_pnl: {total:.2f}")
print()
# Specifically look for the trade we care about
target = 1675593149
match = [x for x in trades if x["ticket"] == target]
if match:
    print(f"Trade {target}: net_pnl = {match[0]['net_pnl']}")
    if match[0]["net_pnl"] == 0.0:
        print("  ^ STILL $0.00 — heal did not run. Needs attention.")
    else:
        print("  ^ Captured correctly.")
else:
    print(f"Trade {target} NOT in JSON.")
