Data quality checks
Every second of market data in Matana Labs passes our checks before a backtest reads it: which trades may set the price, despiking, empty seconds, sessions and bar alignment. The thresholds below are read from the data code when the site is built. Checks reduce errors; they cannot remove all of them.
Stocks and ETFs: which trades set the price
- The price of a second is the volume-weighted average of the trades in it that may set the last price under the consolidated-tape rules. Odd lots, average-price trades, late reports and other condition-coded prints count toward the volume but not the price.
- Off-exchange trades (dark pools, trade-reporting facilities) count toward the volume, not the price: nothing in the order book stood at their price.
- A trade reported more than 10 seconds after it happened does not set the price, and neither does a trade more than 0.75% (and more than one cent) away from the last price. When the market confirms a new level, by 4 trades on it on two venues or over 1 second, the reference moves there, and a lone first print of the session that the market never confirmed is dropped.
- A single trade far from the median of the last 31 accepted trades (by at least 0.10% and 8 typical deviations) is set aside, unless the new level is confirmed by trades on two venues, 4 trades in a row, or it holds for 1 second.
Forex and spot metals
Forex has no central trades, so the price of a second is the last mid-quote (bid + ask) / 2 after filters: empty quotes, crossed quotes, spreads wider than 0.50% and jumps over 0.75% are dropped. Volume is the number of quotes in the second. The trading day runs from 18:00 to 17:00 New York time and is stored by calendar date.
Despiking
A spike is a step in price that goes beyond a threshold and comes back: at least 0.25% for stocks and futures, 0.15% for forex, 0.60% for crypto, and at least 8 typical price steps around it (so a busy hour has a wider threshold); it returns within 15 seconds to within 25% of the jump and stays there. A spike gets the previous price; its volume is kept, because the trades happened. A real move that stays at its new level is not touched. The cleaning runs until nothing changes.
Empty seconds and gaps
A second without trades keeps the previous price with zero volume and is flagged. Nothing fills in a flagged second: an order waits for the next second with trades. By default the day-end close and the end of the range (and the emergency and virtual stops of a long position) still fill in such a second at the carried price, unless exitFill is set to wait for the next real trade (see order execution). Overnight gaps are left as they are: an order whose level the market jumped past fills at the real price after the gap (see order execution).
Sessions and bar alignment
- Stocks and ETFs: the regular session, 09:30 to 16:00 New York time, on the exchange calendar (no session on holidays).
- Bars shorter than a day start at the session open, as on common charting platforms: 45-minute bars on stocks run 09:30, 10:15, 11:00…; the chart, the backtest and the checks use the same grid.
- Every second is labelled by its end (09:30:01 is the second from 09:30:00), so a bar’s last second is inside the bar and the bar is closed from the next one.
Data corrections
Some errors are not single trades but whole sessions or whole stretches of history. We correct them when the data is read; the stored data stays as it is.
- A session that sits on one erroneous trade price all day, or that stopped updating after a trading halt, is left out: charts, backtests and the screener treat it as a day without trading.
- When a ticker belonged to another instrument before (after a merger, a bankruptcy or a ticker change), the history starts on the day the current instrument began trading under it. Backtests and charts don’t offer the earlier data, and the history length shown for the symbol counts from that day.
- A few seconds with a wrong price inside an otherwise good session can be repaired: they are treated as seconds without trades (the previous price, no volume, flagged), and the session’s open, high, low and close are recomputed.
- A daily check looks for new suspects: a session ×1.3 or more away from the days around it that is back the next day; a jump of ×1.8 or more that no split explains, after a gap in the data; a session whose price stood still for 30 minutes while trades kept printing, before a jump of ×1.3 or more. The check never changes data by itself: a person reviews every suspect and approves or rejects the correction.
- Corrections apply to our own stock and ETF data, together with the split adjustment. Data you upload is never changed.
Stock splits
Stock and ETF prices are back-adjusted for splits and reverse splits, so history is continuous in today’s terms; the list of splits is verified against several independent public sources and against the price gap in our own data. See how we handle stock splits.
Extra filters in our research
Our research studies apply further filters before they aggregate across hundreds of instruments: sessions with damaged or too little data are excluded, and splits detected from overnight gaps are back-adjusted. Each study lists how many sessions were excluded and how many adjustments were made, and the data coverage file has them per instrument.