﻿import json, pandas as pd
from pathlib import Path

proj = Path(r"C:\Users\paul_\OneDrive\fx_macro_intraday")

# Live UJ trade history
live_json = proj / "data" / "logs" / "trade_history_usdjpy.json"
if live_json.exists():
    live = json.loads(live_json.read_text(encoding="utf-8"))
    print(f"Live UJ trade history: {len(live)} trades")
    for t in live:
        entry = t.get("entry_time") or t.get("entry") or t.get("open_time")
        print(f"  {entry} | {t.get('direction', '?')} | "
              f"z={t.get('zscore', '?')} | {t.get('exit_reason', '?')} | "
              f"P&L=${t.get('pnl_real', t.get('pnl', '?'))}")

# Backtest CSV — UJ trades in April-May
print()
csv = proj / "data" / "processed" / "usdjpy_trades_real_costs.csv"
df = pd.read_csv(csv)
df["entry_time"] = pd.to_datetime(df["entry_time"])
recent = df[df["entry_time"] >= "2026-04-01"]
print(f"Backtest UJ trades since April 1: {len(recent)}")
for _, t in recent.iterrows():
    print(f"  {t['entry_time']} | dir={t.get('direction','?')} | "
          f"z={t.get('zscore', '?'):.2f} | {t.get('exit_reason','?')} | "
          f"pnl_real=${t.get('pnl_real','?'):.0f}")
