Missing, duplicate and unclosed candles in crypto data
A gap between candle timestamps can mean that no trades took place or that data went missing. A repeated row and an unclosed candle can also change a calculation. We rebuild a day of ETH/USDC from trades, then test three controlled changes on copies of the data.
In simple terms
Start with the expected UTC minutes. Verify an empty interval against the trade archive, consolidate exact duplicates, and use completed bars for a close-based signal. Keep an unresolved gap visible until you can restore or classify it.
On this page01
Build the clock before reading the rows
Write down the venue, market, symbol, interval and timezone. On M1 each expected start is one minute after the previous one. Include trades at the start and assign trades at the next minute boundary to that next minute. This gives a fixed grid even when a feed omits some rows.
02
Rebuild a day from actual trades
We use Binance Spot ETH/USDC on 2024-02-05 UTC. The archive covers 1,440 expected minutes, with trades in 1,349 and no trades in 91. We used 14,669 individual trades to check the minute records. The H1 overview groups the same minutes by hour.
The same day grouped into H1 candles
ETH/USDC · Binance Spot · 2024-02-05 UTC
Open
2,288.66
High
2,293.67
Low
2,277.94
Close
2,279.60
Base volume (ETH)
197.1179
Trades
507
Status
Verified candle
Expected minutes
1,440
Minutes with trades
1,349
Minutes without trades
91
Trades
14,669
The hour bars use the verified minute grid. The counts underneath describe the source day.03
Recognise a confirmed empty minute
At 00:08 UTC the archived trade sequence shows no trade during that minute. The candle archive carries the preceding close across all four prices, with zero volume and zero trades. The dashed mark indicates that carried value. A flat candle with trades can have the same four prices, so inspect the trade count and the underlying sequence.
A verified minute without trades
ETH/USDC · Binance Spot · 2024-02-05 UTC
Open
2,286.68
High
2,286.68
Low
2,286.68
Close
2,286.68
Base volume (ETH)
0.0000
Trades
0
Status
Verified carried close
Trade before the empty minute
Time (UTC)
Trade ID
33997873
Price (USDC)
2,286.68
Trade after the empty minute
Time (UTC)
Trade ID
33997874
Price (USDC)
2,287.16
The dashed line inside the highlighted minute marks the carried close. Adjacent candles are priced from trades.04
Separate an empty interval from lost data
In a copy we remove the real row at 00:20 UTC, which had 23 trades. The chart keeps its time slot open. An omitted empty interval and a lost active row can both appear as a missing timestamp. The underlying trade history distinguishes them. Coinbase Exchange, for example, documents that it leaves out intervals without ticks.
A real minute removed from a copy
ETH/USDC · Binance Spot · 2024-02-05 UTC
Open
—
High
—
Low
—
Close
—
Base volume (ETH)
—
Trades
—
Status
Active row removed
The blank slot is the injected gap. The UTC grid preserves its place. The missing row can be checked against the original tape.05
Recover the candle from the same market
When the trade log has complete coverage of an active minute, take the first, highest, lowest and last trade price for OHLC. Sum the base quantities for volume and count the trades. When the trade history is itself incomplete, keep the gap unresolved and record what you were able to verify.
06
Fix the test rule first
For an active, completed minute, compare its close with the average close of the previous 3 UTC minutes. The flag is true only when the current close is strictly higher. After verification, carry the last close through a minute without trades for this indicator. Require all 3 time slots. Execution needs its own prices and timing.
07
See how a skipped row changes the flag
In the missing-row example the naive calculation takes the latest 3 available rows. It can pull an older price into the window. The strict clock-based calculation pauses while the gap is unresolved. After restoring the archived row, the reference average and flag can be reproduced. The comparison below shows exactly how the reference and naive averages differ.
The missing-row comparison
Verified reference
Minute start (UTC)
00:21
Previous minute starts (UTC)
00:18 · 00:19 · 00:20
Closes used (USDC)
2,285.29 · 2,283.78 · 2,282.50
Average of prior closes (USDC)
2,283.856667
Close being tested (USDC)
2,284.88
Flag
True
Naive calculation
Minute start (UTC)
00:21
Previous minute starts (UTC)
00:17 · 00:18 · 00:19
Closes used (USDC)
2,287.14 · 2,285.29 · 2,283.78
Average of prior closes (USDC)
2,285.403333
Close being tested (USDC)
2,284.88
Flag
False
Unresolved gap
Minute start (UTC)
00:21
Flag
Pending
The reference window uses 3 previous UTC slots. The naive calculation moves back until it finds 3 rows. A strict calculation waits for the missing slot to be restored.08
Check the key before deduplicating
Use the venue, market, symbol, timeframe and opening time as the candle key. Keep one copy of identical final rows. If values disagree for the same key, look up the authoritative record and retain the mismatch for review. An update to a forming candle belongs to that candle until it is final.
09
See what an exact duplicate changes
We repeat the verified row at 00:25 UTC in a copy of the input. The naive latest-3-rows window gives the repeated close extra weight. Deduplication restores one row per minute and recovers the reference calculation. The chart keeps a single time slot for the repeated row.
One minute with an injected repeat
ETH/USDC · Binance Spot · 2024-02-05 UTC
Open
2,291.67
High
2,293.67
Low
2,291.20
Close
2,291.20
Base volume (ETH)
6.2292
Trades
19
Status
Repeated row
Naive calculation
Minute start (UTC)
00:26
Previous minute starts (UTC)
00:24 · 00:25 · 00:25
Closes used (USDC)
2,291.42 · 2,291.20 · 2,291.20
Average of prior closes (USDC)
2,291.273333
Close being tested (USDC)
2,290.21
Flag
False
After deduplication
Minute start (UTC)
00:26
Previous minute starts (UTC)
00:23 · 00:24 · 00:25
Closes used (USDC)
2,286.58 · 2,291.42 · 2,291.20
Average of prior closes (USDC)
2,289.733333
Close being tested (USDC)
2,290.21
Flag
True
The chart keeps a single place for the highlighted minute. Below it, the naive calculation uses the same close twice. Deduplication returns to the reference window.10
Look at a candle while it is forming
For the minute starting at 00:04 UTC we reconstruct the state at 00:04:30 UTC using trades strictly before that cutoff. The provisional and final views show the same minute with different available information. The two candle panels share a price scale.
The same minute at two decision times
ETH/USDC · Binance Spot · 2024-02-05 UTC
At the provisional cutoff
Cutoff (UTC) · 00:04:30 UTC
Open
2,287.70
High
2,287.70
Low
2,287.70
Close
2,287.70
Base volume (ETH)
1.0927
Trades
1
Status
At the provisional cutoff
At the minute close
00:05:00 UTC
Open
2,287.70
High
2,287.70
Low
2,287.54
Close
2,287.54
Base volume (ETH)
1.1836
Trades
3
Status
Verified candle
The highlighted candle is provisional on the first panel and final on the second. Both use the same scale and the same preceding closes.11
Compare the provisional and final signal
Both calculations use the same 3 preceding closes. The forming candle's latest trade price can change before the minute ends. A close-based test can evaluate that minute only after its close is available. The provisional comparison illustrates what would happen if a live snapshot were treated as final.
At the provisional cutoff
Minute start (UTC)
00:04
Previous minute starts (UTC)
00:01 · 00:02 · 00:03
Closes used (USDC)
2,287.24 · 2,287.60 · 2,287.89
Average of prior closes (USDC)
2,287.576667
Close being tested (USDC)
2,287.70
Flag
True
At the minute close
Minute start (UTC)
00:04
Previous minute starts (UTC)
00:01 · 00:02 · 00:03
Closes used (USDC)
2,287.24 · 2,287.60 · 2,287.89
Average of prior closes (USDC)
2,287.576667
Close being tested (USDC)
2,287.54
Flag
False
12
Read closure according to the feed
Use the interval boundary and the source's finalisation rule. In Binance Spot WebSocket kline events, the x field indicates whether the bar is closed. Save the event time and opening time separately. Repeated updates to an open bar are normal. The closing version is the one used in a close-based test.
13
Check timestamp units and continuity
Convert timestamps according to the source format and check the interval spacing after conversion. Binance Spot archive timestamps use microseconds from 1 January 2025. The archived day here uses milliseconds. Check the trading pair and date boundaries along with the clock before classifying any gap.
14
Write down the recovery decision
Keep the original data and label any corrected copy. Record whether a slot is confirmed empty, restored from trades, unresolved, repeated or provisional. Use the same decision in the test and in the review. Indicator continuity and the ability to execute an order are separate questions.
15
Reproduce the comparisons
The JSON contains the archive URLs, checksums, the minute grid, and the original and modified inputs for each example. Rebuild the archived bars, then make each change independently. To avoid rounding at the threshold, test whether 3 times the current close exceeds the sum of the previous 3 closes.
16
What to check before a backtest
Confirm the expected clock grid, check unique keys, verify gaps against the trades and select only bars that were available at decision time. Preserve the source and the recovery rules. Review both the candles and the numeric inputs so a result can be traced back to the data.
Frequently asked questions
Does every missing timestamp mean there were no trades?
Use the underlying trade history and its coverage to classify the interval. If coverage is uncertain, keep it unresolved.
Is a flat candle an empty minute?
A candle can be flat even when every trade happened at the same price. Use verified trades and volume to distinguish it from a carried close.
Can I simply keep the last duplicate row?
Keep one copy of exact repeats. If the final values differ, reconcile the versions with the authoritative source before choosing a row.
Can I use a live candle as the final close?
Use the closing version when a rule depends on the final close. A live snapshot can be used for a separately defined intrabar rule.
Can I carry the previous close across a gap?
Use carry-forward as an explicitly documented feature for confirmed empty intervals. Mark those values separately from traded prices.
Do the examples show a trading return?
They show how data changes a comparison flag. A return calculation also needs entry, exit, sizing and execution costs.