{"record":{"id":"65ae30f33eda18b9","repo":"jackwener/OpenCLI","slug":"unrecognized-symbol-input","errorCode":null,"errorMessage":"Unrecognized symbol: ${input}","messagePattern":"Unrecognized symbol: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/eastmoney/_secid.js","lineNumber":65,"sourceCode":"  }\n\n  // hk prefix\n  const hk = lower.match(/^hk(\\d{4,5})$/) || lower.match(/^(\\d{4,5})\\.hk$/);\n  if (hk) return '116.' + hk[1].padStart(5, '0');\n\n  // us.SYMBOL or SYMBOL.N/.O  (treat all as NASDAQ by default; .N as NYSE)\n  const usDot = lower.match(/^([a-z.\\-]+)\\.([no])$/);\n  if (usDot) return (usDot[2] === 'n' ? '106' : '105') + '.' + usDot[1].toUpperCase();\n  const usPref = lower.match(/^us\\.([a-z.\\-]+)$/);\n  if (usPref) return '105.' + usPref[1].toUpperCase();\n\n  // bare 6-digit Chinese code\n  if (/^\\d{6}$/.test(raw)) return A_PREFIX_TO_MARKET(raw) + '.' + raw;\n\n  // bare US ticker — uppercase letters only\n  if (/^[A-Z.\\-]{1,8}$/.test(raw)) return '105.' + raw;\n\n  throw new Error(`Unrecognized symbol: ${input}`);\n}\n\n/**\n * Normalize a list of user inputs separated by comma / space / Chinese comma.\n * @param {string} s\n * @returns {string[]}\n */\nexport function splitSymbols(s) {\n  return String(s || '')\n    .split(/[,，\\s]+/)\n    .map((x) => x.trim())\n    .filter(Boolean);\n}\n","sourceCodeStart":47,"sourceCodeEnd":79,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/eastmoney/_secid.js#L47-L79","documentation":"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.","triggerScenarios":"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).","commonSituations":"Passing HK tickers like '00700.HK' expecting support; lowercase tickers copied from other tools; Yahoo-style '600519.SS' suffixes; typos in the code length.","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}$/."],"exampleFix":"// before\nresolveSecid('aapl'); // throws\n// after\nresolveSecid('AAPL'); // '105.AAAPL' style US secid\nresolveSecid('600519.SS'.replace(/\\.SS$/i, '')); // 'sh.600519'","handlingStrategy":"validation","validationCode":"const SECID_OK = /^\\d{1,3}\\.[A-Za-z0-9]+$/;\nconst isKnownSecid = (s) => SECID_OK.test(s) && ['0','1','100','105','106','107','116','140','150','151','152','155','156'].includes(s.split('.')[0]);\nconst ACCEPT = /^(sh|sz|bj)\\d{6}$|^\\d{6}$|^[A-Z.\\-]{1,8}$/;\nif (!(isKnownSecid(s) || ACCEPT.test(s))) throw new Error(`Unsupported symbol format: ${s}`);","typeGuard":"const isSupportedSymbol = (s) =>\n  typeof s === 'string' &&\n  (/^\\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));","tryCatchPattern":"try {\n  const secid = resolveSecid(raw);\n} catch (e) {\n  if (e.message.startsWith('Unrecognized symbol')) {\n    console.error(`Cannot map '${raw}' to an Eastmoney secid; use sh/sz/bj+code, a 6-digit code, or an uppercase US ticker.`);\n  } else throw e;\n}","preventionTips":["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"],"tags":["validation","input","secid","symbol-format"],"backgroundTag":"unrecognized-symbol-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}