Data qualityAdvanced

Data Validation

Data validation is the automated gatekeeping layer that verifies market data against explicit schema, range, continuity and cross-source checks before it is allowed into a backtest or a live system, so that corrupt data is rejected rather than silently traded on.

Quick answer: Data validation is the automated gatekeeping layer that verifies market data against explicit schema, range, continuity and cross-source checks before it is allowed into a backtest or a live system, so that corrupt data is rejected rather than silently traded on.

In simple words

Data validation is the set of automatic tests your data must pass before your strategy is allowed to touch it — the equivalent of a pre-flight checklist. It asks: is every field the right type and present, is every value in a plausible range, is the series continuous, and do independent sources agree? Anything that fails is blocked or flagged, so a bad feed stops the system instead of quietly poisoning a live trade.

Purpose

Validation exists as the last line of defence between imperfect data and real money: because data errors are silent and their downstream effects catastrophic, the only safe posture is to prove data is sound before trusting it, every time.

Professional explanation

Schema validation: structure and types

The first layer checks that data has the shape it claims. Every expected field is present, of the correct type (a price is a number, a timestamp is a timezone-aware datetime, a symbol matches a known instrument), and non-null where required. Schema validation catches whole classes of ingestion failure — a shifted column, a missing field after a vendor API change, a string where a number should be, a null volume — before any value-level logic runs. It is cheap, deterministic and belongs at the very edge of the pipeline, because everything downstream assumes the schema holds. In production a schema violation should typically halt ingestion rather than proceed on malformed input.

Range and sanity checks

The second layer checks that values are individually plausible. Prices must be positive and within a sensible multiple of recent levels; a Nifty spot of 2,50,000 or 0 is rejected. Bar-to-bar returns must be within a bound calibrated to the instrument (a liquid index moving 30% in a minute is almost certainly an error). Volume must be non-negative; OHLC bars must satisfy high >= max(open, close) and low <= min(open, close); quotes must not be crossed; prices must respect tick size. Circuit limits give India a natural range check — NSE caps many stocks at 5%, 10% or 20% daily bands, so a move beyond the applicable band is provably impossible and flags corrupt data instantly.

Continuity and completeness checks

The third layer checks the series over time. Is the expected number of bars present for the session (375 one-minute bars on a full NSE day)? Are timestamps monotonic, unique and inside trading hours per the calendar? Are there unexpected gaps within a session for a normally liquid instrument, or duplicate bars from a feed reconnect? Continuity checks catch missing-data and duplication problems that per-value checks cannot see, because each individual value is fine — the fault is in what is absent or repeated. They require a trading calendar and an expected-liquidity model to know what 'complete' means for each instrument on each day.

Cross-source and cross-field reconciliation

The strongest validation compares independent views that should agree. Two data vendors' closes for the same symbol should match within a tolerance; a bar series rebuilt from ticks should reproduce the vendor's bars; a stock's price move should be consistent with its index's move and its sector; an adjusted series should reconcile with raw prices times the known adjustment factors; your recorded fills should match the exchange's trade file. Disagreement between sources that ought to agree is a powerful, hard-to-fool error detector, because a single feed can be confidently wrong but two independent feeds rarely share the same error. This is how subtle corruption that passes every single-source check is finally caught.

Where validation runs, and failing safe

Validation is not a one-time batch job; it runs at every boundary — on historical data before a backtest, on each live tick or bar before it reaches the strategy, and on reference data (corporate actions, calendars) before it is applied. The critical design decision is what to do on failure, and the answer for live trading is to fail safe: block the suspect data, and if the failure is severe or persistent, halt trading or trigger the kill switch rather than act on data you cannot trust. A validation layer that merely logs and proceeds is theatre. Because a corrupt feed can otherwise drive a live algorithm into disastrous orders, validation is properly understood as a risk control that sits alongside the risk engine, not as mere data hygiene.

The four validation layers

LayerChecksExample catch
SchemaFields, types, nullsMissing volume column
RangePlausible valuesNifty printed at 2,50,000
ContinuityCompleteness, order364 of 375 minute bars
Cross-sourceIndependent agreementTwo vendors' closes differ 3%

Practical example

Illustrative example (Indian market)

Suppose your live intraday system ingests Nifty minute bars and, at 11:03, the feed emits a bar with a high of 27,900 while spot has been near 25,000 all morning. A range check computes the one-minute return (about +11%) and the deviation from a rolling robust median (tens of MADs) and rejects the bar; a circuit-context check notes the move exceeds any plausible one-minute band and confirms corruption. The bar is quarantined and the previous valid bar retained, so no false breakout signal is generated and no order is placed on a fiction. Separately, an end-of-day continuity check finds only 372 of the expected 375 bars and a cross-source check shows the official NSE close differs from your feed's close by 0.4%; both are logged for investigation before the next session. Without these automated gates, the 27,900 print alone could have triggered a live order at a phantom level.

NSE's circuit-filter bands (commonly 5%, 10% or 20% for stocks, with index-level market-wide circuit breakers at 10%, 15% and 20%) provide exact, exchange-defined range checks: a single-stock move beyond its applicable daily band is provably impossible and betrays corrupt data, giving a validation rule with no tuning required.

Advantages

  • Blocks corrupt data before it reaches a backtest or, critically, a live order
  • Layered checks (schema, range, continuity, cross-source) catch different, complementary error types
  • Cross-source reconciliation catches subtle corruption that no single-source check can see
  • Exchange rules like circuit bands give exact, tuning-free validation thresholds
  • Turns silent data failure into a loud, actionable stop

Limitations

  • Thresholds too tight reject genuine extreme moves; too loose let errors through — calibration is hard
  • Cross-source checks need a second independent feed, which costs money and adds complexity
  • Validation itself can have bugs, giving false confidence if not tested
  • Continuity checks require an accurate trading calendar and liquidity model per instrument
  • No validation catches every error; some novel corruption always slips through

Common mistakes

  • Building a validation layer that logs failures but proceeds anyway, so it never actually protects a live trade
  • Using fixed absolute thresholds that reject genuine high-volatility days or miss errors on quiet ones
  • Validating historical data before a backtest but not validating the live feed to the same standard
  • Relying on a single source, so a confidently wrong feed passes every check unchallenged
  • Omitting continuity checks, so missing or duplicated bars pass because each individual value looks fine
  • Never testing the validators themselves, so a broken check gives false assurance the data is sound

Professional usage

Mature trading operations run validation as a first-class, tested subsystem at every data boundary, with layered checks — schema, range, continuity, cross-source reconciliation — and explicit fail-safe behaviour that can block data or halt trading. They calibrate thresholds to each instrument's volatility rather than using flat constants, exploit exchange-defined limits (circuit bands, tick sizes) as exact rules, and maintain a second independent feed specifically so cross-source disagreement can surface subtle corruption. Crucially they treat the validators as production code that is itself tested, and they wire severe validation failures into the same kill-switch machinery as risk breaches. The philosophy is that unvalidated data is untrusted by default, and trust is earned per batch, per tick, every time.

Key takeaways

  • Validation is the automated gate that proves data is sound before a backtest or live trade uses it
  • Layer the checks: schema, range, continuity and cross-source reconciliation each catch different errors
  • Cross-source agreement and exchange rules (circuit bands, tick size) are the hardest-to-fool checks
  • For live trading, fail safe — block or halt on failure rather than trade on data you cannot trust

Frequently asked questions

What is data validation in algorithmic trading?
It is the automated layer that verifies market data against schema, range, continuity and cross-source checks before it enters a backtest or live system. Data that fails is rejected or flagged, so corrupt input is stopped rather than silently traded on.
Why is data validation a risk control, not just hygiene?
Because a corrupt feed can drive a live algorithm into disastrous orders, and data errors are silent. Validation is the last line of defence between imperfect data and real money, so it belongs alongside the risk engine rather than being treated as optional tidiness.
What are the main layers of data validation?
Schema (fields, types, nulls), range (plausible values), continuity (completeness and ordering over time), and cross-source reconciliation (independent feeds agreeing). Each catches a different class of error, and together they are far stronger than any single check.
What is schema validation?
Schema validation checks that data has the expected structure — every field present, correctly typed, and non-null where required. It runs at the pipeline edge and catches ingestion failures like a shifted column or a vendor API change before any value-level logic executes.
How do circuit limits help validate Indian market data?
NSE caps many stocks at 5%, 10% or 20% daily bands and applies market-wide index circuit breakers. A single-stock move beyond its applicable band is provably impossible, giving an exact, tuning-free range check that instantly betrays corrupt data.
What is a continuity check?
A continuity check verifies the series over time: the expected number of bars is present (375 per full NSE minute-day), timestamps are monotonic, unique and in session, and there are no unexpected gaps or duplicates. It catches missing and repeated data that per-value checks cannot see.
What is cross-source validation and why is it powerful?
It compares independent views that should agree — two vendors' closes, ticks rebuilt into bars versus vendor bars, adjusted versus raw prices. A single feed can be confidently wrong, but two independent feeds rarely share the same error, so disagreement is a hard-to-fool detector of subtle corruption.
What should happen when validation fails in live trading?
It should fail safe: block the suspect data, and on severe or persistent failure, halt trading or trigger the kill switch rather than act on untrusted data. A validation layer that only logs and proceeds provides no real protection.
How do I set validation thresholds correctly?
Calibrate them to each instrument's volatility rather than using flat constants — a bound that is reasonable for a quiet stock will reject genuine moves on a volatile one and miss errors on a calm one. Exchange-defined limits like circuit bands and tick sizes provide exact thresholds needing no tuning.
Should live and historical data be validated the same way?
Yes. Validating historical data for a backtest but letting the live feed through unchecked leaves the live system exposed to exactly the corruption you screened out of research, and creates an inconsistency between backtest and production inputs.
Can validation reject good data?
Yes, if thresholds are too tight it can flag genuine extreme moves as errors. This is why bounds are calibrated to volatility, exchange limits are used where they give exact rules, and borderline cases are often flagged for review rather than hard-rejected.
Do I need a second data feed for validation?
Not for schema, range or continuity checks, which work on a single source. But cross-source reconciliation — the strongest layer — requires a second independent feed, which costs money and complexity but catches corruption that passes every single-source test.
Should the validators themselves be tested?
Absolutely. Validators are production code, and a broken check gives false confidence that data is sound. They should have their own tests, ideally including known-bad sample data, so you can trust that a pass genuinely means the data is clean.
Where in the pipeline should validation run?
At every boundary — on historical data before a backtest, on each live tick or bar before it reaches the strategy, and on reference data like corporate actions and calendars before they are applied. Validation is continuous gatekeeping, not a one-time batch step.

Voice search & related questions

Natural-language questions people ask about Data Validation.

What is data validation in trading?
It's an automatic checklist your data must pass before your strategy uses it — checking the structure, the values, the completeness, and whether independent sources agree — so bad data gets blocked instead of traded on.
Why do I need to validate my data?
Because data errors are silent and can push a live system into terrible orders. Validation is your last line of defence, catching corruption before it costs you real money.
What should happen if the data fails a check?
In live trading it should fail safe — block the bad data and, if it's serious, halt trading or hit the kill switch, rather than act on numbers you can't trust.
How do circuit limits help check Indian data?
NSE caps how far a stock can move in a day, so any price beyond that band is impossible. That gives you an exact check that flags corrupt data with no guesswork.
What's the strongest kind of validation?
Comparing two independent data sources that should agree. One feed can be confidently wrong, but two rarely share the same mistake, so disagreement reveals hidden corruption.
Should I validate live data as well as historical data?
Yes, to the same standard. If you only check your backtest data, your live system is exposed to exactly the errors you screened out in research.

Sources & references

    Last reviewed 11 July 2026. Educational content only — not investment advice. Markets and rules change; verify current conventions with SEBI, NSE/BSE and your broker.

    Educational content only — not investment advice. Examples use illustrative numbers and simplified models. Algorithmic trading and derivatives involve substantial risk. See our Risk Disclosure and SEBI Disclaimer.