How do you audit perpetual data before running a backtest?

A backtest data audit checks that the intended perpetual instrument has complete, ordered and interpretable observations before strategy results are calculated. Validate identity, timestamps, duplicates, missing intervals and price consistency. Preserve rejected rows and repair decisions in a separate record. A cleaner-looking equity curve cannot establish that its underlying price history was usable.

What does a data acceptance record contain?

Record venue, instrument identifier, linear USDT perpetual contract type, interval, source, collection date, timezone and the field dictionary. Preserve the raw file and an identifiable cleaned version. Include the expected first and last completed bars, row count, unique timestamp count and each validation failure.

Bybit's kline documentation returns records in descending start-time order and notes that an unfinished candle's close is the latest traded price. A backtest expecting ascending completed bars must handle both facts explicitly. Other feeds need their own verified field definitions; this page does not assert that every source has the same ordering or units.

How can a nearly correct row count hide missing candles?

Arithmetic illustration only. A one-hour window from 00:00 to 01:00 Asia/Shanghai contains twelve five-minute start slots,00:00 through 00:55. Suppose the download has eleven records but one timestamp appears twice. There are only ten unique slots, leaving two expected slots absent.

Keeping the first duplicate without inspecting it does not solve the two gaps. If duplicate rows disagree, preserve both and investigate their origin. Check the expected timestamp set directly instead of trusting row count alone. Do not invent candles merely to make the count equal twelve.

How do you complete a five-step data acceptance audit?

  1. Identify the series. Record venue, perpetual instrument, quote and settlement units, interval, timezone, source and collection date. Save the unmodified input with a stable file identifier so later results can be traced to the exact series.
  2. Normalize chronology. Parse timestamps with their documented meaning, order records consistently, and exclude unfinished bars from completed-bar tests. Record the intended start and end of the analysis window before examining performance.
  3. Inspect duplicates and gaps. Compare unique timestamps with the expected interval set. List missing slots and conflicting duplicate rows separately. Investigate the source rather than silently replacing missing observations with the next available price.
  4. Validate values and units. Check numerical fields, positive prices, nonnegative recorded volume, high at least as large as open and close, and low at most as small as open and close. Verify the documented volume units and flag missing values distinctly from zero.
  5. Accept or quarantine explicitly. Save the cleaned version, rejected rows, reasons and any authorized repair procedure. Mark affected test windows unavailable when unresolved defects prevent the intended test, then carry that decision into the research report.

Which consistency checks are useful without overclaiming?

High should also be at least low. Open and close should sit within the reported high/low range. A failed check is a data exception to investigate, not evidence of a profitable anomaly. A successful check establishes only internal consistency, not complete market truth.

Do not declare every zero-volume bar invalid without reading the source convention. Missing volume is not zero volume. Likewise, a sequence of identical prices may be valid or may indicate a collection issue; retain evidence instead of deleting rows because they look inconvenient. Instrument changes and incompatible units require separate segments, not an unlabeled concatenation.

How does the audit affect a strategy comparison?

Use the same accepted dataset for variants you intend to compare. A revised data file is itself a research change; record it in the strategy change log. A result before repair and a result after repair do not isolate a strategy-rule change.

Only after acceptance should you apply causal multi-timeframe rules and the broader backtesting process. This audit does not resolve execution costs, future-information leakage or strategy selection bias. It gives those later checks a traceable input rather than an undocumented price file.

Past performance does not guarantee future results.

What are the short answers on data quality?

Do eleven records mean only one of twelve expected candles is missing?

Not necessarily. If one timestamp is duplicated, eleven records contain only ten unique slots and two expected slots are absent.

Should I fill missing candles with the next known price?

Not silently. That can introduce future information or unsupported observations. Investigate, document a defensible procedure or exclude the affected window.

Does passing OHLC consistency checks validate a backtest?

No. It establishes limited internal consistency. Execution modeling, information timing, costs and research selection still require separate checks.

Leveraged futures carry a high risk of loss.

Last reviewed by Ric Mescallado