jackwener/OpenCLI · warning · EmptyResultError

xueqiu/earnings-date

Error message

xueqiu/earnings-date

What it means

The xueqiu earnings-date command fetches xueqiu's screener event list for a symbol and throws EmptyResultError('xueqiu/earnings-date', ...) when the response has no d.data.items array. This means xueqiu returned a payload without event items — usually because the symbol has no earnings-date records or the symbol/query is wrong.

Source

Thrown at clis/xueqiu/earnings-date.js:28

    browser: true,
    args: [
        {
            name: 'symbol',
            required: true,
            positional: true,
            help: '股票代码,如 SH600519、SZ000858、00700',
        },
        { name: 'next', type: 'bool', default: false, help: '仅返回最近一次未发布的财报日期' },
        { name: 'limit', type: 'int', default: 10, help: '返回数量,默认 10' },
    ],
    columns: ['date', 'report', 'status'],
    func: async (page, kwargs) => {
        await page.goto('https://xueqiu.com');
        const symbol = String(kwargs.symbol).toUpperCase();
        const url = `https://stock.xueqiu.com/v5/stock/screener/event/list.json?symbol=${encodeURIComponent(symbol)}&page=1&size=100`;
        const d = await fetchXueqiuJson(page, url);
        if (!d.data?.items)
            throw new EmptyResultError('xueqiu/earnings-date', '请确认股票代码是否正确: ' + symbol);
        // subtype 2 = 预计财报发布
        const now = Date.now();
        let results = d.data.items
            .filter((item) => item.subtype === 2)
            .map((item) => {
            const ts = item.timestamp;
            const dateStr = ts ? formatChinaDate(ts) : null;
            const isFuture = ts && ts > now;
            return { date: dateStr, report: item.message, status: isFuture ? '⏳ 未发布' : '✅ 已发布', _ts: ts, _future: isFuture };
        });
        if (kwargs.next) {
            const future = results.filter((r) => r._future).sort((a, b) => a._ts - b._ts);
            results = future.length ? [future[0]] : [];
        }
        return results.slice(0, kwargs.limit).map(({ date, report, status }) => ({ date, report, status }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the symbol is correct and formatted per xueqiu conventions (e.g. SH600519, AAPL, 00700).
  2. Check the stock on xueqiu.com to confirm it exists and has earnings events.
  3. Refresh xueqiu cookies (log in) if the API is returning non-data payloads.
  4. Treat it as 'no data available' if the stock genuinely has no earnings-date records.

Example fix

// before
clis/xueqiu earnings-date SH60051   # typo — EmptyResultError
// after
clis/xueqiu earnings-date SH600519
Defensive patterns

Strategy: try-catch

Validate before calling

// validate the symbol before calling
const PATTERN = /^(?:[A-Z]{2}\d{5,6}|\d{4,6}|[A-Z]{1,5}(?:[.-][A-Z]{1,2})?)$/;
if (!PATTERN.test(symbol.toUpperCase())) throw new Error(`bad symbol: ${symbol}`);

Try / catch

try {
  const dates = await getEarningsDate(symbol);
} catch (err) {
  if (/xueqiu\/earnings-date/.test(err.message)) {
    // treat as 'no earnings data for this symbol'; fall back to empty list
  } else throw err;
}

Prevention

When it happens

Trigger: Calling the earnings-date command for a symbol where the list.json response lacks data.items: misspelled or delisted symbol, a symbol with no scheduled/reported earnings events, or an API response shaped differently (auth/anti-bot interstitial yielding a different JSON).

Common situations: Querying OTC or illiquid tickers xueqiu doesn't cover, wrong market code format, symbol typos, or xueqiu cookies expired so the API returns an error object instead of data.

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/ffe857dc72ea6ab1. Report an issue: GitHub.