import json

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

def summarize(bars):
    if not bars: return "No data"
    o, h, l, c = bars[0]['open'], max(b['high'] for b in bars), min(b['low'] for b in bars), bars[-1]['close']
    return f"O:{o:.2f} H:{h:.2f} L:{l:.2f} C:{c:.2f} (from {bars[0]['time_str']} to {bars[-1]['time_str']})"

# Candidate 624: 2026-06-09T00:30:00Z Long
# Candidate 625: 2026-06-09T03:15:00Z Short
# Candidate 626: 2026-06-09T05:15:00Z Long

start_ts = 1775520000 - 86400*3 # 2026-06-03 roughly
end_ts = 1775730000 + 86400*2

print("H4:")
print(summarize(get_bars("hybrid/data/ohlcv_H4.json", start_ts, end_ts)))

c1_start = 1775694600 - 3600 # 2026-06-08 23:30
c1_end = 1775694600 + 3600*4
print("\nC624 M15 (2026-06-09T00:30):")
print(summarize(get_bars("hybrid/data/ohlcv_M15.json", c1_start, c1_end)))

c2_start = 1775704500 - 3600 # 2026-06-09 02:15
c2_end = 1775704500 + 3600*4
print("\nC625 M15 (2026-06-09T03:15):")
print(summarize(get_bars("hybrid/data/ohlcv_M15.json", c2_start, c2_end)))

c3_start = 1775711700 - 3600 # 2026-06-09 04:15
c3_end = 1775711700 + 3600*4
print("\nC626 M15 (2026-06-09T05:15):")
print(summarize(get_bars("hybrid/data/ohlcv_M15.json", c3_start, c3_end)))

