jackwener/OpenCLI · error · EmptyResultError

xueqiu/stock

Error message

xueqiu/stock

What it means

The xueqiu stock command fetches a quote via stock.xueqiu.com/v5/stock/batch/quote.json for the given symbol. If the response has no data.items entries, it throws EmptyResultError('xueqiu/stock', ...) asking the user to confirm the symbol. Like kline, this means the session was valid but xueqiu returned no matching quote.

Source

Thrown at clis/xueqiu/stock.js:37

    description: '获取雪球股票实时行情',
    domain: 'xueqiu.com',
    browser: true,
    args: [
        {
            name: 'symbol',
            required: true,
            positional: true,
            help: '股票代码,如 SH600519、SZ000858、AAPL、00700',
        },
    ],
    columns: ['name', 'symbol', 'price', 'changePercent', 'marketCap'],
    func: async (page, kwargs) => {
        await page.goto('https://xueqiu.com');
        const symbol = String(kwargs.symbol).toUpperCase();
        const url = `https://stock.xueqiu.com/v5/stock/batch/quote.json?symbol=${encodeURIComponent(symbol)}`;
        const d = await fetchXueqiuJson(page, url);
        if (!d.data?.items?.length)
            throw new EmptyResultError('xueqiu/stock', '请确认股票代码是否正确: ' + symbol);
        const item = d.data.items[0];
        const q = item.quote || {};
        const m = item.market || {};
        return [{
                name: q.name,
                symbol: q.symbol,
                exchange: q.exchange,
                currency: q.currency,
                price: q.current,
                change: q.chg,
                changePercent: q.percent != null ? q.percent.toFixed(2) + '%' : null,
                open: q.open,
                high: q.high,
                low: q.low,
                prevClose: q.last_close,
                amplitude: q.amplitude != null ? q.amplitude.toFixed(2) + '%' : null,
                volume: q.volume,
                amount: fmtAmount(q.amount),

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the symbol on xueqiu.com and use xueqiu's exact format (e.g. SH600519, SZ000001, HK00700)
  2. Check the error detail message which echoes the symbol that failed
  3. Confirm the security is still listed/tradeable on xueqiu
  4. Test the symbol against the kline command; if it also fails, the symbol is wrong

Example fix

// before
stock --symbol AAPL
// after
stock --symbol SH600519   // use xueqiu's expected prefixed format
Defensive patterns

Strategy: validation

Validate before calling

const symbol = String(kwargs.symbol || '').toUpperCase().trim();
if (!symbol) {
  throw new Error('symbol is required for the xueqiu stock command (e.g. SH600519)');
}
if (!/^(SH|SZ|HK|US)?[0-9A-Za-z.]{4,10}$/.test(symbol)) {
  throw new Error(`Suspicious xueqiu symbol format: '${symbol}'`);
}

Try / catch

try {
  const q = await xueqiuStock({ symbol: 'SH600519' });
} catch (e) {
  if (/EmptyResultError|xueqiu\/stock/.test(e.message)) {
    console.error(`Quote not found — verify the symbol on xueqiu.com: ${e.message}`);
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a symbol that doesn't resolve on xueqiu (missing market prefix, typo, delisted), or an otherwise valid-looking code the batch quote endpoint doesn't cover.

Common situations: Bare numeric codes without SH/SZ/HK prefixes; old or delisted tickers; US/HK symbols formatted differently than xueqiu expects; copy-paste errors in ticker strings.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a3cb48245b9aa960. Report an issue: GitHub.