Skip to content

fix(collector): support ETN/ETF symbols in name lookup - #13

Merged
mytrashcan merged 1 commit into
mainfrom
fix/etn-name-lookup
Jul 31, 2026
Merged

mytrashcan merged 1 commit into
mainfrom
fix/etn-name-lookup

Conversation

@mytrashcan

Copy link
Copy Markdown
Owner

Summary

Fixes remaining name: null rows on the ranking dashboard for ETN/ETF symbols (0193T0, 0197W0, 0197X0, etc.).

Root cause: The previous fix (PR #12) filtered name lookups to six-digit symbols only. But the Toss name API does support ETN symbols — GET /api/v1/stocks?symbols=0197W0 returns SOL SK하이닉스단일종목레버리지. The strict \d{6} validation in fetchStockNames() rejected those codes, so ETN ranking rows never resolved their display names.

Fix:

  • TossMarketDataClient: added a NAME_LOOKUP_SYMBOL pattern (\d{6}|\d{4}[A-Z0-9]{2}) used only by fetchStockNames() validation. Price/chart endpoints keep the strict \d{6} rule — Toss rejects non-six-digit codes there.
  • StockReferenceService: refreshSymbols() now passes both six-digit and ETN-style codes to the name API, while still filtering out arbitrary junk symbols.

Changes

  • TossMarketDataClient.java: NAME_LOOKUP_SYMBOL pattern + isValidNameLookupSymbol() for validateSymbols()
  • StockReferenceService.java: relaxed refreshSymbols() filter to accept ETN/ETF codes
  • StockReferenceServiceTest.java: test now asserts ETN codes reach the name API and resolve their names

Test plan

  • ./gradlew test --tests 'com.marketguard.collector.StockReferenceServiceTest' --tests 'com.marketguard.collector.client.TossMarketDataClientCharacterizationTest' → pass
  • ./gradlew clean check --no-daemon --no-parallel → BUILD SUCCESSFUL
  • Verified live against Toss API: 0197W0 → SOL SK하이닉스단일종목레버리지

Toss name API supports ETN symbols like 0197W0 (SOL SK하이닉스단일종목레버리지),
but validateSymbols() rejected anything not matching \d{6}, leaving ETN
ranking rows with null names. Allow 4-digit + 2-alphanumeric codes in
name lookups while keeping \d{6} for price/chart endpoints.

@mytrashcan mytrashcan left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Looks good — mergeable

Verified OK

  • Root cause is precise: Toss name API supports ETN symbols (0197W0 → SOL SK하이닉스단일종목레버리지, verified live), but fetchStockNames() validation rejected anything not matching \d{6}.
  • Fix is correctly scoped: NAME_LOOKUP_SYMBOL (\d{6}|\d{4}[A-Z0-9]{2}) applies only to name lookups; price/chart endpoints keep strict \d{6} via KRX_SYMBOL — no behavior change for price data.
  • StockReferenceService.refreshSymbols() filter now admits ETN/ETF codes while still dropping arbitrary junk symbols (e.g. UNKNOWN_SYMBOL never reaches the upstream call).
  • Test updated to prove both directions: ETN codes reach the API and resolve names; junk symbols are filtered out.
  • Full suite passes: ./gradlew clean check → BUILD SUCCESSFUL.

Good Things

  • Verified against the live Toss API before writing the fix — the validation was stricter than the upstream actually is.
  • Separate validation path for name lookups keeps the security posture of price/chart endpoints unchanged.

Reviewed by Hermes Agent - deepseek-v4-flash

@mytrashcan
mytrashcan merged commit 2128e4a into main Jul 31, 2026
1 check passed
@mytrashcan
mytrashcan deleted the fix/etn-name-lookup branch August 3, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant