fix(market): route 5xxxxx ETF codes to Shanghai exchange prefix#16
Merged
Conversation
56xxxx cross-market ETFs (e.g. 563020 红利低波) were incorrectly routed with 'sz' prefix on Sina/Tencent APIs, hitting a different security (bond "新疆2437") and returning price=100.0 instead of ~1.19. This caused guardrails alerts to report 8303% phantom gains. All 5xxxxx codes (51/56 ETFs, 50 funds) belong to Shanghai exchange on quote APIs. Extract _is_sh() helper and include '5' prefix alongside '6' and '9'. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address code review feedback: - Remove secid() which had no consumers in application code - Add 900001 (Shanghai B-share) test case for complete _is_sh() coverage Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
szprefix on Sina/Tencent quote APIs, hitting a different security (bond "新疆2437") and returningprice=100.0instead of~1.19guardrails alertsto report 8303% phantom gains for 5630205xxxxxcodes (51/56 ETFs, 50 funds) now route tosh(Shanghai) prefix via a shared_is_sh()helper, applied tomarket_prefix,secid, andexchange_prefixRoot cause
market_prefix()only checked for6/9prefixes →sh, everything else →sz. But 56xxxx ETFs are cross-market products that route via Shanghai on Sina/Tencent quote APIs. Usingsz563020returns a bond ("新疆2437", price=100), not the ETF.Test plan
sh563020returns correct price=1.188 on both Sina and Tencent APIs🤖 Generated with Claude Code