import json

with open('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/reviews/data_748_751.json', 'r') as f:
    data = json.load(f)

for ts, tfs in data.items():
    print(f"\n--- {ts} ---")
    for tf in ['H4', 'H1']:
        bars = tfs.get(tf, [])
        target_idx = -1
        for i, b in enumerate(bars):
            if b['time'] <= ts:
                target_idx = i
        
        if target_idx != -1:
            start_idx = max(0, target_idx - 3)
            context_bars = bars[start_idx:target_idx+1]
            print(f"{tf} Context:")
            for b in context_bars:
                flag = "-->" if b['time'] == bars[target_idx]['time'] else "   "
                print(f"{flag} {b['time']} | O: {b['open']} | H: {b['high']} | L: {b['low']} | C: {b['close']}")
        else:
            print(f"{tf} Context: No bars found before/at {ts}")
