Missing Data
Missing data is any absent value in a series — from trading halts, holidays, illiquidity, feed outages or corrupt records — and the danger is not the gap itself but the fill: replacing a missing value carelessly, especially by carrying a future value backwards, injects information a real trader never had and biases the backtest.
Quick answer: Missing data is any absent value in a series — from trading halts, holidays, illiquidity, feed outages or corrupt records — and the danger is not the gap itself but the fill: replacing a missing value carelessly, especially by carrying a future value backwards, injects information a real trader never had and biases the backtest.
In simple words
Missing data is the holes in a price history: days the market was shut, a stock that did not trade, a feed that dropped out, or a cell that reads NaN. Every backtest has to decide what to do with these holes, and that decision matters more than it looks. Fill them the wrong way and you either invent prices that never existed or, worse, quietly leak future information into the past.
Purpose
Handling missing data exists because no real dataset is complete, and the method you use to patch the holes is itself a modelling assumption that can add or remove bias without you noticing.
Professional explanation
Why data goes missing
Gaps arise for very different reasons, and the reason dictates the correct treatment. Exchange holidays and weekends are expected absences that a calendar should handle, not a fill. A trading halt or a lower-circuit day means the instrument genuinely could not be traded, so a filled price would misrepresent a period when no exit was possible. Illiquid instruments simply do not print on some days. And feed outages or corrupt records are true data faults where the value existed but was lost. Conflating these — treating a halt like a holiday, or an outage like an illiquid day — produces subtly wrong backtests.
The forward-fill versus back-fill distinction
The single most important rule is directional. Forward-filling — carrying the last known value forward until a new one arrives — is generally safe because it only ever uses information already available at that time. Back-filling — carrying a future value backwards to patch an earlier gap — is dangerous because it inserts a price that was not yet known, a direct form of look-ahead. Interpolating between a past and a future point is a subtler version of the same sin, because the interpolated value depends on data from after the gap. As a default, a backtest should forward-fill or leave gaps explicit, never back-fill prices used for decisions.
Halts and untradeable periods
When an instrument is halted or locked at a circuit limit, the honest model is not to fill a plausible price but to record that no trade was possible. A backtest that fills a halted day with an interpolated price may show an exit or entry that could never have executed, understating the risk of being trapped in a position. This is especially relevant for Indian small and mid caps that hit upper or lower circuits, where a strategy might in reality be unable to sell for several days while the backtest happily books an exit at a made-up price.
NaNs and how they propagate
Explicit missing markers such as NaN are actually safer than silent gaps because they are visible, but they must be handled deliberately before indicators are computed. A single NaN feeding into a moving average or a standard-deviation window can poison the whole window, producing a NaN signal or, if the library silently drops it, a statistic computed over the wrong sample. Worse is a NaN that gets coerced to zero, which a price series reads as a 100 percent crash and a return series reads as a total loss. Every pipeline needs an explicit, logged policy for NaNs rather than relying on a library default.
How the fill choice biases results
Each fill method leaves a fingerprint. Forward-filling a stale price flattens volatility and can suppress or delay signals, making a mean-reversion system look calmer than reality. Interpolation smooths the series and understates true gaps and drawdowns. Filling untradeable halts creates fills that inflate performance by pretending liquidity existed. Even dropping missing rows biases results if the missingness is not random — illiquid or stressed names go missing precisely when they matter most, so deleting them is a quiet cousin of survivorship bias. The correct method is the one whose assumption matches why the data is missing, and it should be stated, not defaulted.
Forward-fill vs Back-fill
| Aspect | Forward-fill | Back-fill |
|---|---|---|
| Direction | Carries last known value forward | Carries a future value backward |
| Look-ahead risk | None — uses only past data | High — inserts future information |
| Effect on series | May flatten volatility if stale | Can invent knowledge of the future |
| Safe for decisions? | Generally yes | No |
| Typical use | Default gap handling | Avoid for anything traded on |
Practical example
Illustrative example (Indian market)
You backtest a portfolio that includes an NSE mid-cap stock which hits its lower circuit for three straight days, printing no tradeable volume, on capital of Rs 5,00,000. Your data has gaps on those three days. If you interpolate a smooth path between the pre-halt price of Rs 480 and the post-halt price of Rs 410, your backtest shows an orderly decline and books an exit at, say, Rs 445 on day two. In reality the stock was locked and you could not have sold at any price until it reopened at Rs 410. The interpolated fill understated your loss by Rs 35 a share and invented liquidity that did not exist. Recording the halt as untradeable, and marking the exit at the real reopening price of Rs 410, produces the honest and far worse outcome.
Indian small and mid caps regularly hit upper or lower circuits, and index constituents observe NSE trading holidays that differ from global calendars. A backtest that treats a circuit-locked day as a normal filled bar, or that misaligns Indian holidays with foreign data in a multi-market test, will book fills that were impossible and generate signals on days the market was shut.
Limitations
- The correct fill depends on why data is missing, and that reason is often not recorded in the feed
- Forward-filling stale prices flattens volatility and can hide real risk
- Any back-fill or interpolation across a gap introduces look-ahead by using post-gap information
- Dropping missing rows biases results when missingness is non-random, as with stressed or illiquid names
- Circuit halts mean no trade was possible, which most fill methods silently ignore
Common mistakes
- Back-filling or interpolating prices that are then used to make trading decisions
- Filling a halted or circuit-locked day with a plausible price and booking a fill that could not have happened
- Letting a NaN be coerced to zero, which reads as a total crash in a price or return series
- Deleting rows with missing values when the missingness is correlated with stress or illiquidity
- Using a library default fill without knowing or logging which method it applied
- Aligning multiple markets without reconciling different holiday calendars, creating false gaps or signals
Professional usage
Serious researchers first classify why a value is missing — holiday, halt, illiquidity or fault — and treat each differently, using a trading calendar for expected absences and marking halts as untradeable rather than filling them. For decision data they forward-fill or leave gaps explicit and never back-fill, and they log every fill so the pipeline is reproducible. They also test sensitivity to the fill choice, because a strategy whose result changes materially with the missing-data policy is resting on an artefact rather than an edge.
Key takeaways
- Missing data comes from holidays, halts, illiquidity and faults, and each needs different handling
- Forward-filling is generally safe; back-filling and interpolation leak future information
- Halted or circuit-locked days should be marked untradeable, not filled with invented prices
- A NaN coerced to zero is read as a total crash, so NaN policy must be explicit
- Dropping non-random missing rows is a quiet form of survivorship bias
Frequently asked questions
What is missing data in a price series?
Why is missing data a problem for backtesting?
What is the difference between forward-fill and back-fill?
Why is back-filling dangerous?
How should I handle a trading halt in a backtest?
What happens if a NaN becomes zero in price data?
Is it okay to delete rows with missing data?
How does forward-filling affect volatility?
How should exchange holidays be handled?
Can interpolation cause look-ahead bias?
Why do different markets create false gaps?
How do I know if my fill method is biasing results?
What is the safest default for missing decision data?
Do NaNs help or hurt data quality?
Voice search & related questions
Natural-language questions people ask about Missing Data.
What is missing data in a backtest?
What is the safest way to fill a gap in prices?
Why is filling a halted day a problem?
Can I just delete the missing rows?
What happens if a missing price becomes zero?
How should I handle stock market holidays in my data?
Sources & references
Last reviewed 12 July 2026. Educational content only — not investment advice. Markets and rules change; verify current conventions with SEBI, NSE/BSE and your broker.