import json
import datetime

with open("hybrid/data/ohlcv_M30.json", "r") as f:
    m30 = json.load(f)["bars"]
with open("hybrid/data/ohlcv_M15.json", "r") as f:
    m15 = json.load(f)["bars"]
with open("hybrid/data/ohlcv_M5.json", "r") as f:
    m5 = json.load(f)["bars"]

timestamps = [
    "2026-01-08T02:45:00Z",
    "2026-01-08T03:30:00Z",
    "2026-01-08T04:15:00Z"
]

def analyze(ts):
    m30_slice = [b for b in m30 if b['time'] <= ts][-4:]
    m15_slice = [b for b in m15 if b['time'] <= ts][-4:]
    m5_slice = [b for b in m5 if b['timestamp'] <= ts][-6:]
    m5_future = [b for b in m5 if b['timestamp'] > ts][:12]
    
    print(f"\n--- {ts} ---")
    print("M30 context:", [(b['time'], b['close']) for b in m30_slice])
    print("M15 context:", [(b['time'], b['high'], b['low'], b['close']) for b in m15_slice])
    print("M5 entry window:", [(b['timestamp'], b['high'], b['low'], b['close']) for b in m5_slice])
    print("M5 future (1 hr):", [(b['timestamp'], b['high'], b['low'], b['close']) for b in m5_future])

for ts in timestamps:
    analyze(ts)

