import json
import sys

def analyze():
    # We will look at data around:
    # 1. 2026-02-13 17:15:00
    # 2. 2026-02-13 18:00:00
    # 3. 2026-02-16 00:00:00

    def get_data(filename, start_ts, end_ts):
        try:
            with open(f"/home/aryy/.hermes/profiles/finance/backtests/xauusd_2026/hybrid/data/{filename}.json") as f:
                data = json.load(f)
                res = [d for d in data if start_ts <= d["timestamp"] <= end_ts]
                return res
        except Exception as e:
            return []
            
    m30_207 = get_data("ohlcv_M30", "2026-02-13T00:00:00Z", "2026-02-13T20:00:00Z")
    m15_207 = get_data("ohlcv_M15", "2026-02-13T16:00:00Z", "2026-02-13T18:30:00Z")
    m15_209 = get_data("ohlcv_M15", "2026-02-15T22:00:00Z", "2026-02-16T02:00:00Z")
    
    print("M30 near 2026-02-13 17:15 (207 & 208)")
    for c in m30_207[-8:]:
        print(f"{c['timestamp']} - O: {c['open']} H: {c['high']} L: {c['low']} C: {c['close']}")
        
    print("\nM15 near 2026-02-13 17:15 and 18:00")
    for c in m15_207:
        print(f"{c['timestamp']} - O: {c['open']} H: {c['high']} L: {c['low']} C: {c['close']}")
        
    print("\nM15 near 2026-02-16 00:00 (209)")
    for c in m15_209:
        print(f"{c['timestamp']} - O: {c['open']} H: {c['high']} L: {c['low']} C: {c['close']}")

if __name__ == "__main__":
    analyze()
