Fix symbol detection in waitForChartReady (~8x faster setSymbol) - #69
Open
AlecuDimitri wants to merge 1 commit into
Open
Fix symbol detection in waitForChartReady (~8x faster setSymbol)#69AlecuDimitri wants to merge 1 commit into
AlecuDimitri wants to merge 1 commit into
Conversation
… exchange prefix waitForChartReady read the current symbol from the DOM legend title, which shows the instrument DESCRIPTION (e.g. "Gold Spot / U.S. Dollar"), not the ticker. Comparing that against an exchange-prefixed symbol like "OANDA:GBPUSD" never matched, so every setSymbol call waited out the full 10s timeout. Now the symbol is read from the chart API (window.TradingViewApi._activeChartWidgetWV.value().symbol(), which returns e.g. "OANDA:GBPUSD"), with the DOM legend as fallback, and the expected symbol is compared without its exchange prefix. Measured: setSymbol went from 10.7s to 1.4s (~8x faster). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
waitForChartReadyreads the current symbol from the DOM legend title ([data-name="legend-source-title"]). That element shows the instrument description (e.g.Gold Spot / U.S. Dollar), not the ticker. When the expected symbol is exchange-prefixed (e.g.OANDA:GBPUSD), theincludes()comparison never matches, so every symbol change waits out the full 10s timeout before returning.Fix
window.TradingViewApi._activeChartWidgetWV.value().symbol()returns the real ticker (e.g.OANDA:GBPUSD) — and fall back to the DOM legend if the API isn't available.OANDA:GBPUSD→GBPUSD), so it still matches when the fallback path returns a bare ticker.Measurements
setSymbol~8x faster, and the wait now actually confirms the symbol switched instead of silently timing out.
🤖 Generated with Claude Code