Repository navigation
sequence-validation - #97
Conversation
- Updated multiple real-time feed classes to include a `validateSequence` parameter in the `_getRealTimeFeeds` method. - Enhanced the `RealTimeFeedBase` class to handle sequence validation, throwing a `SequenceGapError` when sequence discrepancies are detected. - Introduced tests for sequence validation, including scenarios for handling gaps, duplicates, and independent keys. - Adjusted stream functions to support the new `validateSequence` option, ensuring backward compatibility.
…ault and add tests for sequence handling
…lt and add tests for sequence handling
…lt and add tests for sequence handling
…and Aster exchanges
…l-time feed and add corresponding tests
…apshot handling in mappers and tests
…mplement sequence handling in real-time feed with corresponding tests
…d enhance sequence handling with corresponding tests
… message types and sequence validation logic
… with sequence handling and add corresponding tests
…ted type checks for trades and book updates
…lement sequence handling with corresponding tests
…ence handling in real-time feeds with corresponding tests
… with sequence handling and corresponding tests
…sages and add corresponding tests
… handling and add comprehensive tests
…ence handling with comprehensive tests
…ence handling with tests
…ent sequence handling with tests
…ence handling in LighterRealTimeFeed
… improve test coverage
…e handling in MexcRealTimeFeed with tests
…to sequence-validation
…implement error handling tests
…sequence handling in MexcFuturesRealTimeFeed
…e validation in tests
…idation in OkexRealTimeFeed
…uence extraction in PoloniexRealTimeFeed
…quence handling in WooxRealTimeFeed
…add validation for snapshot sequence ID
…and maintainability
… real-time feed classes
…multiple real-time feed tests
…disconnect handling - Removed normalization and disconnect handling from KuCoin, MEXC, OKEx, Poloniex, WhiteBIT, and WOO X tests. - Simplified test cases by eliminating unnecessary complexity while maintaining core functionality. - Updated assertions to reflect changes in message structure and error handling.
…licit parameters for timeout, error handling, and sequence validation
…licit parameters for timeout, error handling, and sequence validation
…nstead of null across multiple real-time feed classes
…eeds and README documentation
…d update tests for snapshot validation
|
A few add special cases the docs don't have (but our recorder has). I'd remove those so this stays the simple, docs-based check it is meant to be:
The rest follow the docs: Binance spot/futures, Aster, Bitget, Bybit, Gemini, Coinbase, Kraken Futures, Delta, Gate.io, HTX, KuCoin, Lighter, MEXC, Poloniex, WhiteBIT and WOO X. None produced a false gap on recorded or live data. On code style, I'd bring the new
|
… tests for consistency
…date snapshot validation tests
… improve related tests
…and simplify tests
…g across various mappers and real-time feeds - Updated DeltaIndia, Deribit, GateIO, GateIOFutures, Gemini, HitBTC, Huobi, Kucoin, KucoinFutures, Lighter, Mexc, MexcFutures, Okex, Poloniex, WhiteBit, and Woox mappers to streamline message type definitions. - Removed redundant export statements for message types that were not utilized. - Simplified sequence extraction logic in real-time feeds by using `any` type for message parameters, enhancing flexibility in handling incoming messages. - Ensured consistent handling of message properties across different exchanges, improving maintainability and readability of the codebase.
…s in Bitvavo, Kucoin, Mexc, and WhiteBit real-time feeds
…n and update related tests
…Huobi real-time feeds and adjust related tests
|
Looks good to me, ready merge and release (minor bump). |
|
Just one small thing in ADD_NEW_EXCHANGE.md - let's not mention recorder there. |
…mental messages in exchange documentation
Adds sequence validation to the live receive path shared by
stream()andstreamNormalized(). Exchange adapters provide sequence information; the shared checker rejects gaps before output, reportsSequenceGapErrorand uses existing connection recovery. Validation defaults totrue;validateSequence: falsedisables continuity checks.Consolidates existing continuous checks from mappers/feeds and adds missing extractors using recorder protocol rules as the reference. Snapshot acquisition, subscriptions and historical mapping stay outside the sequence-only scope unless an integration explicitly requires a local adaptation.
Release notes
Suggested version: minor (new option, new default behavior, no API break).
stream()andstreamNormalized()now validate exchange sequence numbers by default. On a gap the connection reconnects, the error goes toonErrorasSequenceGapError, and normalized books restart from a fresh snapshot. PassvalidateSequence: falseto keep the previous behavior.validateSequenceoption onstream()andstreamNormalized().createRealTimeFeedand the real-time feed base classes keeponErroras the 4th argument;validateSequenceis added after it.Exchange integrations
All 42 integrations have recorded acceptance, with coverage limitations noted below. Checked means required acceptance is complete within the stated coverage, not just that code exists.
binance-futuresbinance-deliverybinancebinance-usasteraster-futuresbitgetbitget-futuresbitvavobullish— dated-future live gap coverage unavailable on quiet markets.bybitbybit-spotbybit-optionsbybit-spread— sparse live fault-injection coverage.coinbasecoinbase-derivatives— historical blocks only.cryptofacilities— inverse perpetuals covered historically.deltadelta-india— historical coverage starts October 29.gate-iogate-io-futures— OBU history starts October 21.gemini— historical checks prove native continuity, not snapshot completeness.hitbtc— recorder's separate timestamp-lag guard is not migrated.huobi-dmhuobi-dm-swaphuobi-dm-linear-swapkucoin— Accepted; present on the PR branch.kucoin-futures— Accepted; snapshot-startup limitation below; present on the PR branch.lighter— Perpetual/spot acceptance recorded; present on the PR branch.lighter-rh— Perpetual and USDG spot books accepted; historical coverage limits below; present on the PR branch.mexc— Spot sequence validation accepted; present on the PR branch.mexc-futures— Acceptance recorded in the plan; present on the PR branch.whitebit— Sequence migration accepted locally; recorded dates November 6–10, no first-of-month coverage yet.okex— Publicbooksaccepted; authenticated TBT channels excluded, matching recorder.okex-futures— Publicbooksaccepted; authenticated TBT channels excluded, matching recorder.okex-swap— Publicbooksaccepted; authenticated TBT channels excluded, matching recorder.okex-options— Publicbooksaccepted; authenticated TBT channels excluded, matching recorder.poloniex—book_lv2accepted; recorded checks use BCH instead of quiet SUI.woo-xderibit— Startup/continuity rules accepted; public.100mslive and recorded.rawverified.huobi— Fresh sequence-only acceptance recorded November 12; snapshot-startup/alignment findings remain open.backpack— Post-release migration accepted; present on the PR branch. Recorded coverage is limited to release-day slices; authenticated public historical replay remains unverified.Findings and outstanding work
prev_change_idlinks or duplicates); gaps reconnect the whole connection instead of resubscribing one book. Live.100ms, recorded.raw, omission/opt-out and book reconstruction checks passed.book_lv2lastId→idperdata[0].symbol, and snapshots reset the chain, matching recorder. Live, recorded, omission/opt-out and reconstruction checks passed.bookslinksprevSeqId→seqIdperinstId, including inside batches, matching recorder. Authenticated TBT channels are excluded, as in recorder.past_update_id→update_idper market, snapshots reset). Recorded coverage starts November 6, so there is no first-of-month sample.fromVersion - 1→toVersion; Futures validatesbegin - 1→endwithversionfallback, both per symbol, matching recorder. Live, recorded and omission/opt-out checks passed.begin_nonce→nonceper channel, and snapshots reset, matching recorder. RH recordings start September 23, so only two first-of-month dates exist.level2data.sequence/sequence - 1per symbol, matching recorder; live, recorded and omission/opt-out checks passed. Outstanding: stale REST snapshots cause full reconnects (12 in 90 s on 10 contracts); a recorder-style per-symbol retry removed them but is left for a separate PR, decision pending.trade.l2updatesequenceEnd/sequenceStart - 1per symbol, matching recorder. Live, recorded and omission/opt-out checks passed with no errors or disconnects.prevSeqNumagainst the previousseqNumper symbol, matching recorder; snapshots do not reset the chain. Live, recorded and omission/opt-out checks passed.orderbookupdateprevTs→tsperdata.s, matching recorder; REST snapshots do not reset the chain. Outstanding (separate PR): the REST snapshot can be older than the first applied update (2 of 9 books live), and neither Node nor recorder checks this alignment.U - 1→uper symbol), matching recorder. The mapper retains buffering, stale-update suppression and the first live update’s snapshot overlap check, including withvalidateSequence: false. Native and normalized live checks passed across six spot/perpetual markets. Three release-day slices covered 138,578 depth/snapshot messages; 71,758 normalized messages exactly matched the released mapper, and 36 omission/opt-out controls passed. Public historical API attempts returned HTTP 401 without an API key; recorded slices were replayed through a local HTTP fixture. Multi-date/first-of-month coverage is not yet available.Validation and tracking
Validation (November 17): local Node 26.12.1
npm testpassed all 512 tests, including build and test type checks;npm run check-formatpassed. Backpack live, recorded-data, reconnect, opt-out and receive-path throughput checks passed. Node 24 and the broaderRUN_LIVE_TESTS=1suite were not rerun for this migration. The earlier November 16 GitHub CI passed on Node 24.22.1 and 26.12.1 (492 tests); those results predate the Backpack migration. Each integration has live and recorded-data checks, with the limits noted above.The workspace plan,
plans/tardis-node-realtime-sequence-validation.md, owns detailed per-integration evidence and outstanding work. Keep this description's 42-entry checklist, pending reasons, findings and summary counts synchronized with that plan whenever migration status changes.