Find missing candles in OHLCV history

Define the expected clock before checking candle counts. BTC/USD on a continuous hourly series has one bucket per UTC hour. A stock’s minute series follows the venue calendar, so after-hours and holidays require separate treatment. Compare the expected index with the actual start of each closed candle.

Inspect a one-hour hole

An hourly dataset contains 00:00, 01:00 and 03:00 UTC. The expected 02:00 row is missing. A return from 01:00 close to 03:00 close then spans two hours. An SMA with length 3 still consumes three rows, but it no longer covers the intended three consecutive hours.

In a continuous market, group the missing timestamps by consecutive ranges and log each range’s source. Inspect duplicates separately. Duplicate rows may be revised responses for the same candle and should be reconciled by provider and update time.

Keep missing and zero volume distinct

Look up the provider’s rule for intervals with no trades. If you have a documented zero-trade candle, keep that classification. Unknown gaps should have a missing flag. If a model requires equally spaced observations, consider restarting its warm-up after a gap or treating the whole test segment as invalid. For live collection store when each gap was repaired, so a replay reflects what the strategy knew then.

Export Kraken candles to CSV · Resample minute candles into closed hours