Skip to content

feat: reject non-standard symbols (missing CODE.MARKET format) - #556

Closed
hogan-yuan wants to merge 2 commits into
mainfrom
feat/us-symbol-validation
Closed

feat: reject non-standard symbols (missing CODE.MARKET format)#556
hogan-yuan wants to merge 2 commits into
mainfrom
feat/us-symbol-validation

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Summary

Add validate_symbol / validate_and_convert to rust/src/utils/counter.rs and apply to all SDK methods that accept a single symbol parameter.

Bare tickers like "AXTI" that are missing the required CODE.MARKET format are now rejected with a clear error, instead of silently being passed as-is to the API.

Changes

  • rust/src/utils/counter.rs: new validate_symbol(&str) -> Result<()> and validate_and_convert(impl Into<String>) -> Result<String>
  • rust/src/fundamental/context.rs: all 37 methods with symbol param (9 US + 28 non-US)
  • rust/src/quote/context.rs: 9 methods (depth, brokers, trades, candlesticks, option_volume, etc.)
  • rust/src/trade/context.rs: margin_ratio + us_query_orders optional symbol filter

Python/Node.js/Java inherit validation automatically via Rust delegation.

Error

invalid security symbol: AXTI (expected CODE.MARKET format, e.g. "AAPL.US")

Test plan

  • Bare tickers (AXTI, AAPL, "") → rejected before any network call
  • Standard format (AAPL.US, 700.HK) → accepted
  • us_query_orders with no symbol still works (optional field)

Add validate_symbol() to rust/src/utils/counter.rs and apply it to:
- All 9 US fundamental methods (us_company_overview, us_valuation_overview,
  us_financial_overview, us_financial_statement, us_key_financial_metrics,
  us_analyst_consensus, us_etf_dividend_info, us_company_dividends, us_etf_files)
- us_crypto_overview (quote context)
- us_query_orders optional symbol filter (trade context)

Bare tickers like "AXTI" now return InvalidSecuritySymbol error.
Blocking wrappers inherit validation via async delegation.
Add validate_and_convert() to counter.rs. Apply to:
- All 28 non-US fundamental methods
- 8 quote methods (depth, brokers, trades, intraday, candlesticks, etc.)
- 2 trade methods (margin_ratio, us_query_orders)
@huacnlee huacnlee closed this Jul 20, 2026
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.

2 participants