jackwener/OpenCLI · error · Error
Unrecognized symbol: ${input}
Error message
Unrecognized symbol: ${input} What it means
resolveSecid() throws 'Unrecognized symbol' when the trimmed input matches none of the accepted shapes: an existing secid with a KNOWN_MARKET_PREFIXES market, sh/sz/bj + 6 digits, a bare 6-digit code, or an uppercase US ticker (letters . - up to 8 chars). The input is well-formed enough to be non-empty but not a symbol format this library understands.
Source
Thrown at clis/eastmoney/_secid.js:65
}
// hk prefix
const hk = lower.match(/^hk(\d{4,5})$/) || lower.match(/^(\d{4,5})\.hk$/);
if (hk) return '116.' + hk[1].padStart(5, '0');
// us.SYMBOL or SYMBOL.N/.O (treat all as NASDAQ by default; .N as NYSE)
const usDot = lower.match(/^([a-z.\-]+)\.([no])$/);
if (usDot) return (usDot[2] === 'n' ? '106' : '105') + '.' + usDot[1].toUpperCase();
const usPref = lower.match(/^us\.([a-z.\-]+)$/);
if (usPref) return '105.' + usPref[1].toUpperCase();
// bare 6-digit Chinese code
if (/^\d{6}$/.test(raw)) return A_PREFIX_TO_MARKET(raw) + '.' + raw;
// bare US ticker — uppercase letters only
if (/^[A-Z.\-]{1,8}$/.test(raw)) return '105.' + raw;
throw new Error(`Unrecognized symbol: ${input}`);
}
/**
* Normalize a list of user inputs separated by comma / space / Chinese comma.
* @param {string} s
* @returns {string[]}
*/
export function splitSymbols(s) {
return String(s || '')
.split(/[,,\s]+/)
.map((x) => x.trim())
.filter(Boolean);
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Uppercase bare US tickers before calling: resolveSecid(sym.toUpperCase()).
- Convert unsupported formats yourself: '600519.SS' → '600519', '00700.HK' is not supported — use its numeric code only if a supported market applies.
- Use a market prefix ('sh600519', 'sz000001', 'bj832000') or a bare 6-digit A-share code for Chinese stocks.
- Verify the symbol matches one of: /^\d{1,3}\.[A-Za-z0-9]+$/ with a known market prefix, /^(sh|sz|bj)\d{6}$/, /^\d{6}$/, or /^[A-Z.\-]{1,8}$/.
Example fix
// before
resolveSecid('aapl'); // throws
// after
resolveSecid('AAPL'); // '105.AAAPL' style US secid
resolveSecid('600519.SS'.replace(/\.SS$/i, '')); // 'sh.600519' Defensive patterns
Strategy: validation
Validate before calling
const SECID_OK = /^\d{1,3}\.[A-Za-z0-9]+$/;
const isKnownSecid = (s) => SECID_OK.test(s) && ['0','1','100','105','106','107','116','140','150','151','152','155','156'].includes(s.split('.')[0]);
const ACCEPT = /^(sh|sz|bj)\d{6}$|^\d{6}$|^[A-Z.\-]{1,8}$/;
if (!(isKnownSecid(s) || ACCEPT.test(s))) throw new Error(`Unsupported symbol format: ${s}`); Type guard
const isSupportedSymbol = (s) =>
typeof s === 'string' &&
(/^\d{1,3}\.[A-Za-z0-9]+$/.test(s) || /^(sh|sz|bj)\d{6}$/.test(s) || /^\d{6}$/.test(s) || /^[A-Z.\-]{1,8}$/.test(s)); Try / catch
try {
const secid = resolveSecid(raw);
} catch (e) {
if (e.message.startsWith('Unrecognized symbol')) {
console.error(`Cannot map '${raw}' to an Eastmoney secid; use sh/sz/bj+code, a 6-digit code, or an uppercase US ticker.`);
} else throw e;
} Prevention
- Uppercase US tickers before calling resolveSecid
- Strip Yahoo-style suffixes (.SS/.SZ) and market prefixes you know are unsupported (e.g. .HK)
- Keep a reference list of accepted formats near the call site
- Validate against the four accepted regexes before invoking
When it happens
Trigger: resolveSecid('AAPL12345678') (too long), resolveSecid('aapl') (lowercase bare ticker — regex requires uppercase), resolveSecid('00700.HK') (HK code, no prefix in KNOWN_MARKET_PREFIXES), resolveSecid('60051') (5 digits), resolveSecid('600519.SS') (unsupported suffix style).
Common situations: Passing HK tickers like '00700.HK' expecting support; lowercase tickers copied from other tools; Yahoo-style '600519.SS' suffixes; typos in the code length.
Related errors
- empty symbol
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search query must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/65ae30f33eda18b9.
Report an issue: GitHub.