Artificial intelligenceIntermediate21 min read

Did the market change, or did your data feed break?

Diagnose stale market data, clock errors and distribution shifts before retraining, using a worked two-feed incident.

A partly clear window looks onto a foggy landscape, with a fuchsia cloth on the sill.
A conceptual photograph of the view and the glass through which we see it.

The quote that would not move

At 09:14:15 UTC the quote on a research dashboard is still 1.10420 bid and 1.10424 ask. The connection indicator has turned green again. An incoming heartbeat has just reset its timer. The same pair of numbers was on the screen at 09:14:02. A model that consumes the displayed price sees almost no movement, while its spread input looks comfortably familiar. Did the market become unusually quiet? The light answers a narrower question than the researcher needs it to answer.

Consider this a hypothetical EUR/USD incident. Both feeds, all records, their circumstances, model behavior and every number used in the investigation are invented. The research system consumes provider A and archives its incoming messages before parsing. A separate collector receives provider B directly and saves its own raw records. B is available as a comparison for the investigation.

There are several ways to earn a green indicator. A transport can deliver control traffic while a symbol subscription is stalled. Fresh prices can arrive while a filter rejects them. A valid quote can also be reissued with the same prices. Even a functioning subscription may deliver sparse updates according to its contract. OANDA, for example, documents up to four prices per second per instrument over 250 ms windows, with some prices omitted, and heartbeats every five seconds. Those properties are specific to that stream. Silence by itself gives no general basis for declaring a market closed. OANDA pricing stream

Start by stating which object is frozen. The screen reports a cached quote. The feature store might be writing rows every second using that cache. The upstream adapter might be receiving prices throughout. Each observation belongs to a different layer and comes with a different test. Ask whether the latest eligible price event advanced at each boundary. Eligibility includes the instrument, quote type, timestamp validity and any configured freshness limit.

A heartbeat is evidence about the path it actually traversed. Record it in its own series. Give price progress a separate indicator whose age comes from price records. This separation makes it harder for a healthy socket to lend credibility to a frozen market input.

Three clocks answer three questions

In the example, A’s last accepted quote carries event time 09:14:00 UTC. The first local collector records receipt at 09:14:01 UTC. The feature processor accepts it at 09:14:02 UTC. At 09:14:15 UTC the displayed quote is 15 seconds old on the event clock, 14 seconds old since receipt and 13 seconds old since processing. On synchronized clocks, the original delivery took one second and the local processing stage another second. There are 13 further seconds between acceptance and the observation on the dashboard.

Three clock lanes show the event at second zero, receipt at second one and processing at second two, with observation at second fifteen.
The hypothetical quote has three recorded times. The heartbeat at second fifteen leaves quote age at fifteen seconds.

Keep the clock owner alongside each field. Event time is the instant the publisher associates with a quote, according to its documented meaning. Receive time is when your collector records arrival, ideally at a named ingress point. Processing time is when your pipeline accepts or emits a usable representation. In a distributed pipeline there can be several processing times. A durable feature write and a calculation in memory can be separated by a retry, so name the precise boundary the field describes.

A growing gap between capture and feature publication suggests a local queue or processing problem. Long delivery delays with a short local processing gap point farther upstream, provided clock alignment is credible. If the publisher clock is fast, subtracting event time from receive time can produce a negative value. Clamping it to zero hides a clue. Use a local monotonic clock for elapsed durations inside one process and retain UTC wall times for cross-system alignment. Forex timestamps and availability

The collector should attach receipt time before handing data to a queue. Stamping it when a consumer drains the queue can make a late batch look newly delivered. Likewise, a retry should preserve the original receipt and separately record its own attempt. In a replay, ask what was accessible by the simulated decision deadline. Event time locates observations in market time. Receipt and acceptance establish the information boundary. A historical file sorted solely by event time can make timely data appear where a live researcher would have had an empty input.

Unchanged, stale and missing

A fresh quote can be unchanged. Suppose A normally issues a new valid timestamp when it republishes a quote, and both sides remain exactly 1.10420 and 1.10424. Under that contract, a newly accepted record advances event time without changing either price. A zero difference in price is compatible with an advancing stream. A protocol that publishes only on change supplies different evidence and may need an explicit snapshot query or subscription status to interpret a quiet interval.

A stale quote is an earlier observation whose age exceeds a declared limit for a particular consumer. Suppose the feature job has an illustrative five-second freshness budget and marks anything strictly older than five seconds as stale. The quote at 09:14:15 fails. Its age of 15 seconds is ten seconds above the limit. A slow research product that samples once a minute might have a different contract. A suitable budget depends on collection semantics, the decision horizon and how much lateness a downstream calculation can tolerate.

A missing observation is one for which the expected slot or key contains no eligible record. The application may still display an older quote in a separate cache. For a candle builder that expects samples in a particular minute, the absence of eligible samples is a statement about that minute, even though the dashboard has something to print. Store missingness explicitly, with a reason when known. An absent symbol, a quarantined record and a period outside the applicable schedule lead to different investigations. Where delivery is event-driven, define the expected slot at the consuming layer before counting gaps.

A diagnostic matrix compares evidence for an unchanged, stale or missing quote and how each is represented.
A carried quote and an empty observation slot can coexist. The classification depends on the consuming contract.

Under a hypothetical cache policy, the interface can display the last seen quote with its age while feature construction returns an unavailable value. That preserves context and avoids manufacturing a market observation. If a model was trained with missingness indicators, give it the representation it was evaluated on and stay within its supported conditions. An unfamiliar pattern of missing inputs may justify withholding even a shadow score until the implications are understood. The diagnostic comparison remains valuable whether or not a prediction is produced.

Read the raw evidence before comparing charts

At 09:14:03 collector A receives a message with an event time of 09:14:02 and a bid of 1.10422 and ask of 1.10426. At 09:14:05 another A message arrives with an event time of 09:14:04 and a bid of 1.10424 and ask of 1.10428. Both are original archived records. The normalized output contains neither. The heartbeat at 09:14:15 has its own control message and still makes it through.

Collector B receives a quote at 09:14:05 with event time 09:14:04, bid 1.10423 and ask 1.10429. Suppose its preceding eligible quote had different prices. The second feed is an independent witness because collection and parsing paths are separate. It establishes that its own visible quote changed. The exact quote that A should have supplied remains a separate question. Two streams can represent different venues, liquidity, quote sizes or delivery sampling. Identical timestamps can refer to different stages of quote formation. Independently collected providers can also share an upstream dependency, which limits corroboration.

Compare the same instrument, compatible quote representations and a short matching window with a maximum tolerated time gap. Count how many records failed to find a counterpart. Selecting the closest earlier eligible record suits a time-causal reconstruction if receipt is also checked. A later record can be useful as explicitly retrospective forensic evidence. If streams have different update frequencies, report the match rate beside the distribution of price differences. Restricting analysis to conveniently matched records can hide precisely the interval you are investigating.

What strengthens the diagnosis here is the comparison within A. The collector archived fresh records, the normalizer emitted no new price and the heartbeat branch continued. The upstream subscription delivered the particular messages at issue. Pull the rejection reasons and compare the parser contract with the actual fields. B widened the investigation beyond a frozen chart. The raw and normalized records from A now make it possible to locate the break. Preserve the exact bytes and normalizer version for that comparison. Raw record identifiers enable the diagnosis to survive later revisions to a chart or curated dataset.

Check the capture boundaries before treating this kind of archive as complete. Record which subscriptions the collector believed it had and whether disk writes succeeded. If the provider and channel supply sequence identifiers, inspect discontinuities under that protocol’s rules, including resets on reconnect. Where no identifiers exist, preserve the weaker evidence of transport counts and capture interruptions. A surviving raw record establishes that this message reached the archive. Silence in an incomplete archive is much harder to interpret.

A schema or unit change can look like a regime

In the archive, the rejected A price records use a different timestamp representation. The earlier valid price used an ISO timestamp and the parser expected that representation. The rejected records carry integer epoch milliseconds. The price branch emits a type error. The heartbeat follows a separate decoder. A controlled replay of the archive with the original normalizer reproduces the selective rejection. A candidate decoder with an explicit versioned mapping accepts the same records and preserves their intended UTC instants. The replay tests the explanation at the boundary where the observable failure occurred.

Imagine instead a permissive implementation that interprets milliseconds as seconds. Its output could be far outside the valid time range, or fail a library conversion. A fallback that replaces implausible times with current time could make old records look fresh. A robust contract declares the timestamp unit and epoch, tests expected bounds and treats unknown encodings as uncertain. Recognition by magnitude alone is weak when vendors have versioned message shapes. It may also be ambiguous in synthetic fixtures or for unusual epochs.

Scale errors have their own fingerprints. Take the first A quote. Ask minus bid is 0.00004, which is 0.4 pips if one pip is defined as 0.00010 for this example. If a field describing tenths of a pip is consumed as whole pips, the encoded value 4 becomes an apparent four pips, ten times the intended spread. Everything can stay positive and pass basic finite-number checks. Median spreads can jump across instruments simultaneously, and a model may lower scores for reasons entirely consistent with its training. A monitor of schema and units can catch the assumption that a distribution chart merely reflects.

Check instrument identity, bid and ask ordering, decimal scales and the semantics of any quote-size field. Sample calculations from raw values next to their normalized representation. A schema fingerprint can flag changed field types or optionality, but an unchanged shape can carry a changed meaning. Agree on which values count as plausible for each contract and retain samples around a rollout. A migration from mid to bid changes what a feature represents even if its column name and numeric type remain identical. Bid, ask and spread in Forex

A candle inherits its construction rules

Suppose an audit fixture reconstructs the 09:14 UTC minute using just the three A price records, with no later records in the fixture. The builder uses midquotes, groups by the event-time interval from 09:14:00 inclusive to 09:15:00 exclusive, and orders accepted records by event time with a documented tie-breaker. The three mids are 1.10422, 1.10424 and 1.10426. Open and low are therefore 1.10422, high and close 1.10426, and the range is 0.00004. With just the first accepted record, all four values are 1.10422 and the range is zero. A minute sampled under a different feed contract might legitimately produce either shape.

The pipeline could also generate a flat candle when no records arrive during the minute, by building from sampled cache values. That output has different evidence from a one-record candle. Add an observed record count, cache reuse count and coverage status. Keep record count separate from trade volume. Three quote records mean three observations of a publisher’s quote, with no implied count of executions. Ten repeats of a cached price are ten uses of one observation. Deduplicate according to a documented identity rule. Two separate events with the same price may both be legitimate.

Event-time boundaries deserve tests precisely where they look boring. A record stamped 09:15:00 belongs to the next minute under the fixture’s rule. A record from 09:14:59 that arrives after publication may enter a corrected candle. The earlier published version remains the one the pipeline saw. Choose a lateness policy that says when a bar is provisional, when it is eligible for features and when a new revision is made. A downstream calculation that needs the close must wait for its declared availability.

A reconstructed candle and the candle available at the original cutoff are separate records. Version them and retain the builder definition. Compare recomputed bars after bringing price basis, time boundaries, duplicates and lateness rules into alignment. A difference in highs can be genuine sampling variation between vendors. The forensic test here holds the vendor and raw A records fixed and changes parser behavior. That isolates how a measurement defect erased an observed range without requiring an assumption about the true market path.

A changed mixture can move the input distribution

Call the model’s inputs X, including spread, recent observed range and any flags it actually consumes. A change in P(X) means the observed input distribution differs between two populations or windows. That observation needs a definition of the population. A window with many more observations from one session can show a new overall distribution while both session-specific distributions stay exactly as before. The same effect can occur if an outage leaves observations from only a subset of instruments.

Consider a second hypothetical calculation, independent of the three-record fixture. Use one observation per eligible minute and two session strata, quiet and active. In each window, 20% of quiet-session observations fall in a wide-spread bin, compared with 60% in the active session. The reference contains 80 quiet minutes and 20 active minutes. The wide bin gets 16 quiet plus 12 active observations, or 28 of 100. The current sample contains 40 quiet and 60 active minutes. The bin gets 8 quiet plus 36 active observations, or 44 of 100. The increase is 16 percentage points. The complementary narrow bins contain 72 and 56 observations.

Stacked narrow and wide spread bins show 72 and 28 observations in the reference and 56 and 44 in the current sample.
The pooled wide-spread share rises from 28% to 44%. Within each session the rate stays at 20% or 60%.

Apply the reference weights to the current rates. The result is 0.80 times 0.20 plus 0.20 times 0.60, or 0.28. Composition explains the pooled alert by construction. The higher aggregate rate is still real for the observed mixture. If the mix is a legitimate change in the research population, it changes how often the model encounters wide spreads. If quiet minutes are missing because collection failed, the same arithmetic describes selection by the pipeline.

Report both estimates with the counts behind them. If a stratum disappears entirely, computing its current rate is impossible. A reweighted figure that silently imputes the historical rate would hide the coverage problem. Report supported strata separately and mark the full standardized comparison unavailable. Narrower matching controls more composition effects at the cost of fewer data in each cell. Tie groups to the feed schedule and feature design, with enough observations to identify routine sparse periods.

Outcomes mature on their own timetable

Define Y for a hypothetical model as whether the midpoint exceeds its starting value thirty minutes after a decision, using a specified label feed and sampling rule. A decision stamped 09:14:15 needs an observation at its prescribed horizon around 09:44:15, plus whatever arrival or correction allowance the label pipeline declares. At 09:20 an analyst can inspect X, prediction logs and missingness. That decision’s Y is pending. Report pending labels separately and restrict the performance denominator to eligible matured cases, so that an empty label cannot accidentally become a negative outcome.

Once labels mature, a shift in P(Y) means outcome frequencies changed in the observed eligible population. The change may follow from a new mixture of X even if the relationship between X and Y is stable. A change in P(Y|X) means outcome behavior differs for comparable input conditions. Imagine a hypothetical score band whose matured positive fraction falls from 55% to 45%. If the band contains a different balance of sessions or other inputs, it compares two mixtures of cases. A common score can summarize different feature profiles. Restrict comparisons to overlapping support, show what was excluded and report uncertainty that reflects dependence across nearby observations.

The label channel needs its own forensic checks. If corrected A quotes determine the label, a repair could change both start and end values. If labels use B, B’s event time, price basis and missingness policies still matter. A bad label can manufacture apparent degradation on a healthy input stream. A rule that delays labels more often in active periods can also bias the early view of performance. Record the fraction matured and the fraction successfully matched by each analysis cutoff, and compare cohorts at equal maturity.

Measure input change when possible and estimate outcome change on eligible matured cohorts. An engineering diagnosis can be solid while a drift investigation remains unresolved. The monitor can observe fewer updates this minute. The label study can later ask whether the relationship under comparable measurement changed. Signs of both can coexist. A dated cohort manifest is useful because revisions can move both numerator and denominator while the report keeps the same title.

The cutoffs also affect how you interpret a join. The observation used to establish the starting midpoint must have been available under the study’s starting-price rule. The observation used for the endpoint must satisfy the separate horizon rule. In an audit table, keep the target endpoint, the actual matched event and the time the label first became available. These fields expose a horizon that has lengthened simply because the join waited for the next price after a gap.

Build monitors around the evidence they supply

A layered design starts at ingestion. Count control and price messages separately, track reconnects and inspect timestamp validity, symbol coverage and out-of-order arrivals. Monitor normalization with accepted and rejected price counts and rejection reasons tied to parser versions. At feature construction, measure age, proportion of cached values, coverage by session and basic domain checks. A final layer tracks prediction and outcome behavior on fixed cohorts. Give each indicator an owner, denominator and action. A monitor of unchanged prices should specify whether it counts numerically unchanged observations or intervals with no newly accepted record.

Use session-matched references for noisy comparisons. A live Monday pre-open should be compared to genuinely comparable historical periods as defined by the instrument and feed. Match by time relative to an agreed schedule, account for holidays and changes in daylight saving, and keep lineage and builder versions visible. A baseline that automatically absorbs a bad week can legitimize an incident in its next refresh. Choose a fixed reference for diagnosis and independently review any reference updates. Log supporting counts even when an alert is suppressed for too few eligible observations.

Persistence can filter one-off deviations. Define an illustrative investigation rule requiring three consecutive eligible five-minute windows with an elevated wide-bin share relative to matched history, subject to a minimum sample size. Specify the bin edge in advance and say how missing windows break the streak. A format violation or hard freshness budget can trigger immediate quarantine because the evidence points to unusable input for that consumer. The persistence rule handles statistical fluctuations, while hard invariants have their own response.

Multiplicity matters when hundreds of series and windows are tested. In a hypothetical set of 20 independent tests at a 5% false-positive rate under each null, the expected number of false alarms is one and the chance of at least one is about 64.2%, from one minus 0.95 to the twentieth power. Actual series and rolling windows are often dependent. Treat that calculation as an illustration, organize alerts by shared symptoms and calibrate alert load on representative clean history. There is no universal drift statistic or threshold. The NIST AI RMF Playbook discusses ongoing monitoring and response arrangements in MANAGE 2.2 and 4.1. The layered policy here is an original application. NIST AI RMF Playbook

Count expected opportunities as well as observed rows. In the mixture example both windows contain one hundred observations, but the counts say nothing about how many minutes the collectors were supposed to cover. Build that expectation from the agreed schedule and the research sampling rule. A coverage report can then distinguish a legitimate change in scheduled composition from a sample reshaped by failed collection. It also exposes duplicate observations that would otherwise inflate the apparent depth of a comparison.

Put decisions and observations in the ledger

At 09:14:15 the operator records the affected instrument, last accepted event and freshness breach. The first action is quarantine of the uncertain input at the consumer boundary. Record what quarantine affects. The cached quote remains viewable for diagnosis with its age, the incident cohort is excluded from valid feature output, and collectors keep preserving evidence. Make the reason machine-readable so a downstream reader can distinguish late arrival, invalid schema and an intentional hold. Neighboring instruments have their own quality states.

A four-row ledger pairs recorded evidence with quarantine, replay, revision and shadow comparison decisions.
Each decision has an evidence entry, from the first quarantine to review of shadow scores.

The next ledger entry identifies the raw records and failing normalizer version. The timestamp error can be reproduced using those inputs. Record the candidate version, compatibility rule and replay scope before evaluating the repair. A decoder that accepts both rejected records yet mishandles the next boundary can move the symptom into the candle builder. Include a valid old format, an unknown format and a late record in the audit fixture. Store expected and observed effects so someone who was absent can repeat the diagnosis. A note that only says “feed issue resolved” gives a future reviewer little basis to distinguish a transport recovery from a parser change.

Then document uncertainty in the attribution. We have evidence of a specific defect in A’s price normalization and evidence that B observed changing quotes. We have limited evidence about the broader market. The two feeds could be consistent once their sampling rules are understood. An entry for that uncertainty prevents ticket closure from turning into a conclusion about market stability. If several issues are suspected, record independently what would falsify each diagnosis.

Treat held records as part of the evidence. Knowing a row was deliberately withheld is important when reconstructing what a model could have observed. Storage and retention rules can constrain how long raw material is kept, so the ledger should identify retained evidence and coverage. A reproducible record of versions, windows and decisions is also the purpose of a research experiment journal. The ledger adds a time-sensitive account of data quality and authority for each change. Research experiment journal

Corrections and backfills need two histories

Suppose a separate hypothetical segment has independent clock audit evidence that the source clock was two seconds fast over a bounded interval. A raw event at 09:15:01 would map to 09:14:59 and cross the minute boundary. The audit needs the sign, magnitude, supported interval and uncertainty of the offset. Where its validity is ambiguous near a boundary, mark affected records explicitly. Inferring a constant shift from price agreement with B alone would be weak, since differences in sampling, delivery and quote formation could produce a similar apparent lag.

Apply clock mapping and schema correction as versioned derivations from the raw data. Update affected bars and downstream windows in a new revision. A record moving across the minute boundary affects two bars, and rolling features that consume either bar can remain affected for their lookback. Labels that use endpoints in the repaired interval may need revision. Keep origin identifiers so the new representations can be traced to the same records. Use an explicit cutover condition and have repeated runs with the same inputs and version yield the same outputs, with one copy of each bar and correction entry.

Completeness depends on capture history. A backfill from A’s archive can recover observations the parser rejected if the archive is intact. If the collector dropped messages, a later vendor history product may contain differently sampled prices or candles. Assess that product under its own contract. A substitute from B is a distinct source and can support a separately labeled analysis. Merging it silently into A would erase differences that matter to learning and the incident audit.

Preserve the as-observed history and publish a separately identifiable corrected history. In a hypothetical replay, the corrected 09:14 bar may be useful to measure how much the parser error distorted a feature. The original explains availability at the incident cutoff. Backfill arrival time is part of the corrected history. Keep original receipt times attached to the original capture. Record counts and correction scope after backfill, and identify which cohorts use which history. Analysts can then reproduce a question about knowledge at the time or a question about a repaired dataset from the corresponding records.

Validate the output by comparing affected and unaffected partitions. A difference outside the declared impact window warrants investigation, especially where a rolling feature extends that window. If readers consume several derived tables, give them one revision identifier for the whole set so they can read mutually consistent bars, variables and labels. A partially completed write should remain out of the research view until its coverage checks are complete. A repeatable calculation and an identifiable published snapshot address different failure points.

Compare fixed models before considering retraining

After quality checks, freeze the model artifact, feature definitions, preprocessing and scoring configuration. Run shadow-only comparisons over a common eligible cohort. In one pass use the historical input view. In another use the repaired A view with its revision identified. Keep predictions separate from execution. For observations that cannot be scored under the original contract, report the gap in coverage. Where both versions produce scores, inspect paired changes and relate them to fields actually repaired. If B enters a diagnostic experiment, label it as a separate source and establish its feature mapping. Changing model and data in one comparison makes attribution difficult.

Use the stored fit for preprocessing. A newly estimated scale or imputation value could absorb an issue and make the repaired-versus-original comparison misleading. Scikit-learn’s guidance applies the learned training transformation consistently to held-out data and keeps test data out of fitting. A frozen artifact applies that principle to this incident comparison. Scikit-learn common pitfalls

Inspect where score differences cluster by session, time or field. In the fixture the repaired candle has a nonzero range where the original had zero. A model that uses range may respond, and a model that does not use it can provide a comparison if its own inputs are unaffected. Keep differences in eligibility visible. Treat paired results as descriptive until matured, checked labels make an outcome analysis possible. A restored prediction distribution can be consistent with repaired measurement and still leave the market relationship unresolved.

Decide what would justify a later training study. If fresh records stabilize and matched inputs return to their reference ranges, document the measurement explanation for those metrics. If quality checks pass but a distribution difference persists across supported strata, investigate its origin and test whether matured outcome behavior changes on comparable support. Keep an untouched evaluation cohort and record the reason for any candidate design. Retraining on the uncertain interval risks teaching the model the behavior of the malfunction.

To practice checking timestamps, quote definitions and feature availability with Forex examples, use the Forex demo for study and testing.

Back to the Blog