import json

with open("hybrid/data/ohlcv_H4.json", "r") as f:
    h4 = json.load(f)["bars"]
with open("hybrid/data/ohlcv_H1.json", "r") as f:
    h1 = json.load(f)["bars"]

ts = "2026-06-25T07:45:00Z"

out = {"h4": [], "h1": []}

for i, b in enumerate(h4):
    if b["time"] > ts:
        out["h4"] = h4[max(0, i-4):i]
        break

for i, b in enumerate(h1):
    if b["time"] > ts:
        out["h1"] = h1[max(0, i-6):i]
        break

print("HTF Context for 2026-06-25:")
print(json.dumps(out, indent=2))
