import json

def get_bars(file_path, start_time, count=5):
    with open(file_path) as f:
        data = json.load(f)
    
    if isinstance(data, dict) and 'bars' in data:
        data = data['bars']
        
    bars = []
    for bar in data:
        if bar['time'] <= start_time:
            bars.append(bar)
    
    return bars[-count:]

print("--- candidate_2026-07-13T04-45-00Z_long_liquidity_sweep_reversal ---")
h4 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_H4.json', "2026-07-13T04:45:00Z", count=5)
print("H4:")
for b in h4: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")
h1 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_H1.json', "2026-07-13T04:45:00Z", count=6)
print("H1:")
for b in h1: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")
m30 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_M30.json', "2026-07-13T04:45:00Z", count=6)
print("M30:")
for b in m30: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")

print("\n--- candidate_2026-07-13T15-00-00Z_short_liquidity_sweep_reversal ---")
h4 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_H4.json', "2026-07-13T15:00:00Z", count=5)
print("H4:")
for b in h4: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")
h1 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_H1.json', "2026-07-13T15:00:00Z", count=6)
print("H1:")
for b in h1: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")
m30 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_M30.json', "2026-07-13T15:00:00Z", count=6)
print("M30:")
for b in m30: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")

print("\n--- candidate_2026-07-13T16-00-00Z_short_liquidity_sweep_reversal ---")
h1 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_H1.json', "2026-07-13T16:00:00Z", count=6)
print("H1:")
for b in h1: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")
m30 = get_bars('/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/ohlcv_M30.json', "2026-07-13T16:00:00Z", count=6)
print("M30:")
for b in m30: print(f"  {b['time']}: O={b['open']} H={b['high']} L={b['low']} C={b['close']}")
