{"record":{"id":"56858a2dd945af48","repo":"jackwener/OpenCLI","slug":"xueqiu-kline","errorCode":null,"errorMessage":"xueqiu/kline","messagePattern":"xueqiu/kline","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/xueqiu/kline.js","lineNumber":29,"sourceCode":"    args: [\n        {\n            name: 'symbol',\n            required: true,\n            positional: true,\n            help: '股票代码，如 SH600519、SZ000858、AAPL',\n        },\n        { name: 'days', type: 'int', default: 14, help: '回溯天数（默认14天）' },\n    ],\n    columns: ['date', 'open', 'high', 'low', 'close', 'volume'],\n    func: async (page, kwargs) => {\n        await page.goto('https://xueqiu.com');\n        const symbol = String(kwargs.symbol).toUpperCase();\n        const days = kwargs.days;\n        const beginTs = Date.now();\n        const url = `https://stock.xueqiu.com/v5/stock/chart/kline.json?symbol=${encodeURIComponent(symbol)}&begin=${beginTs}&period=day&type=before&count=-${days}`;\n        const d = await fetchXueqiuJson(page, url);\n        if (!d.data?.item?.length)\n            throw new EmptyResultError('xueqiu/kline', '请确认股票代码是否正确: ' + symbol);\n        const columns = d.data.column || [];\n        const colIdx = {};\n        columns.forEach((name, i) => { colIdx[name] = i; });\n        return d.data.item.map(row => ({\n            date: colIdx.timestamp != null ? formatChinaDate(row[colIdx.timestamp]) : null,\n            open: row[colIdx.open] ?? null,\n            high: row[colIdx.high] ?? null,\n            low: row[colIdx.low] ?? null,\n            close: row[colIdx.close] ?? null,\n            volume: row[colIdx.volume] ?? null,\n            percent: row[colIdx.percent] ?? null,\n            symbol,\n        }));\n    },\n});\n","sourceCodeStart":11,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xueqiu/kline.js#L11-L45","documentation":"The xueqiu kline command requests daily candlestick data from stock.xueqiu.com/v5/stock/chart/kline.json for a given symbol. If the response contains no data.item array entries (empty kline series), it throws EmptyResultError('xueqiu/kline', ...) with a hint to verify the symbol. This distinguishes an authenticated-but-empty response from an auth failure.","triggerScenarios":"Calling kline with a symbol that xueqiu doesn't recognize (bad format, wrong market prefix, delisted code), or a symbol that exists but has no daily kline data for the requested count/days window.","commonSituations":"Using a bare code like '600519' without market prefix when needed (e.g. SH600519/SZ000001); typo'd or invented tickers; querying a delisted or newly listed stock with no history; non-A-share codes not supported by this endpoint.","solutions":["Verify the symbol on xueqiu.com and use the correct prefixed format (e.g. SH600519, SZ000001, HK00700)","Check the error's detail message, which includes the exact symbol that was queried","Confirm the stock is actively listed and has daily history for the requested days","Try a smaller days value to rule out a range issue, though symbol is the usual culprit"],"exampleFix":"// before\nkline --symbol 600519\n// after\nkline --symbol SH600519","handlingStrategy":"validation","validationCode":"const SYMBOL_RE = /^(SH|SZ|HK|US)?[0-9A-Za-z.]{4,10}$/;\nconst symbol = String(kwargs.symbol || '').toUpperCase().trim();\nif (!SYMBOL_RE.test(symbol)) {\n  throw new Error(`Invalid xueqiu symbol format: '${symbol}' (expected e.g. SH600519, SZ000001, HK00700)`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const k = await xueqiuKline({ symbol: 'SH600519', days: 30 });\n} catch (e) {\n  if (/EmptyResultError|xueqiu\\/kline/.test(e.message)) {\n    console.error(`No kline data — check the symbol format: ${e.message}`);\n  } else if (/AuthRequiredError/.test(e.message)) {\n    console.error('Log in to xueqiu.com and retry.');\n  } else throw e;\n}","preventionTips":["Always use xueqiu's prefixed symbol format (SH/SZ/HK + code)","Cross-check symbols against xueqiu.com search before batch queries","Skip delisted/inactive tickers in your symbol lists","Distinguish EmptyResultError (bad symbol) from AuthRequiredError (session) when handling"],"tags":["empty-result","xueqiu","validation","symbol"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}