When should a market data service switch back to WebSocket after using snapshots?
TickDB Research ·
When should a market data service switch back to WebSocket after using snapshots?
A market dashboard can move backward in time if it returns to streaming on the first message after an outage. We replayed historical Cambricon prices with injected failures to compare two switchback rules and provide an acceptance check for on-call engineers.
Your dashboard uses snapshots during a streaming outage. The stream reconnects and delivers a first update stamped 10:04. The display already shows a snapshot stamped 10:06. Switching back immediately would show an older update and could feed a discontinuity into an alert rule. The on-call decision is when to change the display source and when to resume alerts that require continuous data.
Check business data after the connection recovers
TickDB WebSocket supplies streaming updates. REST snapshots can refresh the latest observed state during a gap. Keep source timestamps for both. Before switching back, check that the subscription is delivering valid messages for the intended symbol, then compare their source time with the displayed value. Heartbeats, subscription confirmations and unrelated symbols do not count. Check quote age separately to catch streams that advance but are still too far behind. TickDB Stock Market Data API
Replay the same events with two rules
This offline replay uses closing values of one-minute Cambricon 688256.SH bars from November 12, 2026. We injected the arrival order and failures to produce a delayed message, a second outage and sustained recovery. Times below are historical bar labels. The replay does not use the production WebSocket or measure network latency. [1–2]
| Injected sequence | Switch back on the first primary message | Reject old messages and require three increasing source times |
|---|---|---|
| Primary goes down, snapshot advances to 10:06 | Display snapshot | Display snapshot |
| First primary message arrives with label 10:04 | Switch back and display 10:04 | Reject older message and keep snapshot |
| Primary drops again, snapshot advances to 10:07 | Fall back again | Keep snapshot |
| Primary delivers 10:08, 10:09 and 10:10 | Switch back at 10:08 | Switch back at 10:10 and ignore the repeated 10:10 |

The first drop counts as a transition in both cases. The immediate rule made four transitions and one source-time regression. The stability rule made two transitions and no source-time regressions. With the replay cut off after 10:09, two valid messages were insufficient to switch back. The comparison changes both timestamp validation and the message count. The result applies to the combined policy. In the replay, an advancing snapshot, another outage or a rejected candidate resets the count. Three is a test threshold. Set it for your feed cadence, sessions and tolerance for delay.
Give the on-call team an acceptance check
For each symbol, log the displayed source time, candidate timestamp, valid streak, current state and alert eligibility. During fallback, show the snapshot time and pause alerts that depend on continuous updates. Count a business message only when its source time is later than both the displayed value and the preceding candidate. This example isolates the ordering check.
def may_count(source_minute, displayed, last_candidate):
return source_minute > displayed and (
last_candidate is None or source_minute > last_candidate
)
shown = "10:06"
print(may_count("10:04", shown, None))
print(may_count("10:08", shown, None))
print(may_count("10:08", shown, "10:08"))
False
True
False
These comparisons use bar labels for one day and symbol. Use comparable full timestamps in production. Exercise the stale-message, stable-recovery and prolonged-silence branches. If a snapshot is absent or too old, display unavailable. After switching sources, rebuild or backfill any window needed by continuous alerts before re-enabling those alerts.
Frequently asked questions
What if the price has not changed? Use the business message's source time and the instrument's trading status. An unchanged price alone cannot diagnose a connection.
Does switching back recover all missed messages? The replay verifies switchback behavior and display time. Test historical recovery, gaps and recalculation separately for tasks that depend on a complete window.
References
- TickDB Docs, WebSocket quickstart and market snapshot fields.
- TickDB historical sample, 688256.SH, November 12, 2026, 10:03–10:11 Shanghai time, unadjusted one-minute bars. Failures, snapshot delivery and arrival order were injected locally.
This week’s offer

November 23–29, 2026, through 23:59 Beijing time. Save 15% on six months and get an extra half month, or save 20% on a year and get an extra month. Eligible for new paid subscriptions and renewals.
7 markets · 43,111 symbols
- US stocks
- 14,809
- Hong Kong market
- 3,354
- China stocks, ETFs & bonds
- 7,576
- Forex & metals
- 1,228
- Indices
- 13,960
- Futures
- 1,172
- Crypto
- 1,012