Compare REST and WebSocket Observations by Semantic State

By DX Research Group · · Market data

A versioned quote fixture separates normal observation lag from a true adapter disagreement.

Compare REST and WebSocket adapters at an equivalent documented state, using the same fields and units. A REST response and a stream update can disagree simply because they observed different moments. We would diagnose parity by matching their boundaries first, then inspecting values, rather than treating any simultaneous client reads as an exact equality test.

Coinbase's full-channel reconstruction procedure uses a REST snapshot and queued stream messages together. It illustrates why transport paths can support one reconstructed state while their raw responses remain different observations.

One market, two valid versions

Assume a fictional protocol with comparable book versions. REST returns snapshot version 900 with bid 100 and ask 101. The stream has already applied version 901, changing the ask to 102. The client receives both responses during the same local millisecond.

ObservationVersionBidAsk
REST snapshot900100101
Stream state901100102
REST plus update 901901100102

Raw equality fails, while reconstructed equality at version 901 succeeds. The local receipt coincidence gives no reason to erase the version difference. If the aligned stream still shows ask 101 at version 901, the fixture contains a real reconstruction mismatch to investigate.

Decide what equality should include

Match market scope, depth limit, aggregation, and quantity convention before comparing. A top-of-book endpoint and a multi-level book represent overlapping information, with parity defined only for their common fields. An endpoint that rounds prices to a display precision needs a declared comparison tolerance or exact decimal normalization consistent with its documentation.

Where the source supplies no shared sequence, compare under an explicitly bounded observation window. Save the original responses and classify the result as approximate. A close match establishes agreement within that window, rather than proving exact venue-state equality.

Account streams deserve a separate parity contract. A user-only channel may omit unrelated market events, and a balance channel may represent a different scope from a complete account response. Test the documented common quantities before interpreting absence as a lost event.

A proposed shadow comparison

Run both adapters without changing agent actions. For each aligned comparison, record successful matches, mismatched fields, and cases that lack a valid common boundary. Keep alignment failures in the denominator. A low mismatch rate among a tiny aligned subset can conceal broad coverage gaps.

Feed selected mismatches into a saved fixture: stale stream state, rounded decimal, wrong depth limit, and a genuinely missing update. Require the diagnostics to distinguish these mechanisms. Our depth-unit note supports checking common quantity conventions. Our frozen-input guidance supports preserving the comparison payloads. This protocol can measure adapter agreement and coverage. An agent-quality study would then freeze equivalent observations and compare decisions separately, so a transport change does not become an unsupported claim about forecasting skill.

Sources

Related field notes