Fix replay mode symbol resolution to use fully-qualified symbol (EXCHANGE:SYMBOL) - #230
Open
randomshinichi wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reproduce the problem
TV_AUTH_TOKEN="$TV_AUTH_TOKEN" cargo run --example export_index_btcusd_1m_backfill -- --symbol BTCUSD --exchange INDEX --tf 1m --from 2026-02-01 --to 2026-02-19 --out-dir /tmp/tv-reproIf you want a single command that also prints detected minute gaps right after export:
Summary
This fixes an issue in replay mode where symbol resolution used the bare symbol (e.g. BTCUSD) instead of the fully-qualified symbol (e.g. INDEX:BTCUSD).
In my backfill runs, this caused subtle data quality problems:
missing 1m bars (small gaps),
and mismatched OHLCV vs TradingView/tvdatafeed for the same timestamps.
Root cause
In set_replay(...), resolve_symbol(...) was called with &options.symbol (bare symbol), while non-replay path uses symbol ({exchange}:{symbol}).
So replay requests were not consistently scoped to the intended market/exchange.
Fix
In src/live/websocket.rs (set_replay), changed:
to:
where symbol is already built as "{exchange}:{symbol}".
Why this is correct
set_market builds the fully-qualified symbol once and passes it to set_replay.
resolve_symbol should receive the same symbol format in replay and non-replay paths for consistent behavior.
Validation
I validated this with repeated BTCUSD INDEX backfills:
Before fix: reproducible 1m gaps in exported CSV (e.g. missing minute bars around specific timestamps).
After fix: same export flow produced gap-free 1m output for the previously failing range; bar counts and continuity aligned with expected cadence.
Scope
Minimal change (single-line behavior fix in replay path)
No API changes
No behavior change for non-replay mode