Overall Statistics
Total Orders
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Start Equity
100000.00
End Equity
100000
Net Profit
0%
Sharpe Ratio
0
Sortino Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
Drawdown Recovery
0
from AlgorithmImports import *

class KrakenGapRepro(QCAlgorithm):
    def initialize(self):
        self.set_time_zone(TimeZones.UTC)
        self.set_start_date(2026, 8, 30)
        self.set_end_date(2026, 8, 31)
        self.set_cash(100000)
        self.xrp = self.add_crypto("XRPUSD", Resolution.MINUTE, Market.KRAKEN).symbol
        self.btc = self.add_crypto("BTCUSD", Resolution.MINUTE, Market.KRAKEN).symbol
        self.schedule.on(self.date_rules.on(2026, 8, 30), self.time_rules.at(23, 50), self.check_history)

    def check_history(self):
        start = datetime(2026, 8, 30, 18, 0, 0)
        end = datetime(2026, 8, 30, 22, 0, 0)
        for sym, label in [(self.xrp, "XRPUSD"), (self.btc, "BTCUSD")]:
            hist = self.history(sym, start, end, Resolution.MINUTE)
            n = len(hist)
            expected_minutes = int((end - start).total_seconds() // 60)
            if n == 0:
                self.log(f"{label}: EMPTY history for {start}->{end} (expected~={expected_minutes})")
                continue
            idx = hist.index.get_level_values('time') if hasattr(hist.index, 'get_level_values') else hist.index
            times = list(idx)
            gaps = []
            for i in range(1, len(times)):
                delta = (times[i] - times[i-1]).total_seconds() / 60
                if delta > 1:
                    gaps.append((str(times[i-1]), str(times[i]), delta))
            self.log(f"{label}: bars={n} expected~={expected_minutes} first={times[0]} last={times[-1]} num_gaps={len(gaps)}")
            for g in gaps[:10]:
                self.log(f"{label} GAP: {g[0]} -> {g[1]} ({g[2]} min)")