jackwener/OpenCLI · warning · CliError

NO_DATA

NO_DATA

Error message

`No ${key} data returned`

What it means

After a successful HTTP call, northbound.js reads data.data[key] where key is 's2n' (southbound) or 'n2s' (northbound). If that field is missing or not an array, rows is [] and the command throws CliError NO_DATA with `No ${key} data returned`. This means eastmoney responded successfully but the payload contained no minute-bar series for the requested direction.

Source

Thrown at clis/eastmoney/northbound.js:41

  func: async (args) => {
    const dir = String(args.direction ?? 'north').toLowerCase();
    if (!['north', 'south', 'n', 's'].includes(dir)) {
      throw new CliError('INVALID_ARGUMENT', `Unknown direction "${dir}". Valid: north / south`);
    }
    const limit = Math.max(1, Math.min(Number(args.limit) || 10, 240));

    const url = new URL('https://push2.eastmoney.com/api/qt/kamtbs.rtmin/get');
    url.searchParams.set('fields1', 'f1,f2,f3,f4');
    url.searchParams.set('fields2', 'f51,f52,f54,f56');
    url.searchParams.set('ut', 'b2884a393a59ad64002292a3e90d46a5');

    const resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
    if (!resp.ok) throw new CliError('HTTP_ERROR', `northbound failed: HTTP ${resp.status}`);
    const data = await resp.json();
    const key = (dir === 'south' || dir === 's') ? 's2n' : 'n2s';
    /** @type {string[]} */
    const rows = Array.isArray(data?.data?.[key]) ? data.data[key] : [];
    if (rows.length === 0) throw new CliError('NO_DATA', `No ${key} data returned`);

    // CSV fields per entry: "HH:MM,cumulative_net(万), minute_net(万), total_net(万)"
    // Drop rows with '-' (after market close or before open). Convert 万元 → 亿元 for readability.
    const valid = rows
      .map((r) => r.split(','))
      .filter((c) => c.length >= 4 && c[1] !== '-');
    if (valid.length === 0) {
      throw new CliError('NO_DATA', `${key} has no valid minute data yet (markets may not be open)`);
    }
    return valid.slice(-limit).map(([time, cum, min, total]) => ({
      time,
      cumulativeNetYi: +(Number(cum) / 10000).toFixed(4),
      minuteNetYi: +(Number(min) / 10000).toFixed(4),
      totalNetYi: +(Number(total) / 10000).toFixed(4),
    }));
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run the command during mainland A-share / HK trading hours (09:30–15:00 CST, weekdays)
  2. Confirm it is not a HK Connect holiday (Connect closed days yield empty feeds)
  3. Inspect the raw API response (curl the URL) to see whether data.data.s2n/n2s exists
  4. If keys changed, update the key mapping in clis/eastmoney/northbound.js

Example fix

// before
const rows = Array.isArray(data?.data?.[key]) ? data.data[key] : [];
// after — fallback to the opposite key or a clearer diagnostic
const rows = Array.isArray(data?.data?.[key]) ? data.data[key]
  : Array.isArray(data?.data?.s2n) ? data.data.s2n : [];
Defensive patterns

Strategy: fallback

Validate before calling

function isTradingWindow(d = new Date()) {
  const day = d.getDay(); const h = d.getHours() + d.getMinutes() / 60;
  return day >= 1 && day <= 5 && ((h >= 9.5 && h < 11.5) || (h >= 13 && h < 15));
}
if (!isTradingWindow()) console.warn('Outside A-share trading hours — empty feeds are expected');

Type guard

const hasFeed = (data, key) => Array.isArray(data?.data?.[key]) && data.data[key].length > 0;

Try / catch

try {
  await runNorthbound(args);
} catch (e) {
  if (e.code === 'NO_DATA') console.warn(`Eastmoney feed empty for this direction/session — likely off-hours or holiday. ${e.message}`);
  else throw e;
}

Prevention

When it happens

Trigger: The kamtbs.rtmin/get endpoint returns ok HTTP but data.data is null, or lacks the requested 'n2s'/'s2n' array — typically outside trading hours, during HK-mainland market holiday closures, or when eastmoney's feed is empty/partially degraded.

Common situations: Running the command on weekends, Chinese public holidays, or before market open; running after market close when eastmoney clears the intraday series; eastmoney API schema changes renaming the s2n/n2s keys; requesting southbound data on days when HK Connect south flow is suspended.

Related errors


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