
import json

def get_bars(filepath, start, end):
    with open(filepath) as f:
        data = json.load(f)
    bars = data.get('bars', [])
    res = []
    for b in bars:
        t = b['time']
        if isinstance(t, int):
            from datetime import datetime, timezone
            t = datetime.fromtimestamp(t, tz=timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
        if start <= t <= end:
            res.append((t, b))
    return res
    
print("\nM5 early:")
bars = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_M5.json', '2026-01-13T06:00:00Z', '2026-01-13T10:45:00Z')
for t, b in bars:
    print(f"{t} O:{b['open']} H:{b['high']} L:{b['low']} C:{b['close']}")
