import json
from datetime import datetime, timezone

def iso_to_ts(iso_str):
    return datetime.fromisoformat(iso_str.replace('Z', '+00:00')).timestamp()

def get_bars(file, start_ts, end_ts):
    with open(file) as f:
        data = json.load(f)
    if 'bars' in data:
        bars = data['bars']
    else:
        bars = data
    return [b for b in bars if start_ts <= iso_to_ts(b['time']) <= end_ts]

print("C624 Long (2026-06-09T00:30): M5 context")
c1_start = iso_to_ts("2026-06-08T23:30:00Z")
c1_end = iso_to_ts("2026-06-09T01:30:00Z")
for b in get_bars("hybrid/data/ohlcv_M5.json", c1_start, c1_end):
    print(f"M5 {b['time']}: O:{b['open']} H:{b['high']} L:{b['low']} C:{b['close']}")
