jackwener/OpenCLI · warning · CliError
NO_DATA
NO_DATA
Error message
eastmoney returned no money-flow data
What it means
The eastmoney money-flow CLI throws CliError('NO_DATA') when the endpoint returns HTTP 200 but `data.data.diff` is absent or empty — i.e. the API succeeded structurally but returned no capital-flow rows. This separates 'upstream returned nothing' from transport errors and from invalid-argument errors, and unlike error 1356 its message is static (no parameters interpolated).
Source
Thrown at clis/eastmoney/money-flow.js:63
];
const url = new URL('https://push2.eastmoney.com/api/qt/clist/get');
url.searchParams.set('pn', '1');
url.searchParams.set('pz', String(limit));
url.searchParams.set('po', po);
url.searchParams.set('np', '1');
url.searchParams.set('fltt', '2');
url.searchParams.set('invt', '2');
url.searchParams.set('fid', range.fid);
url.searchParams.set('fs', A_MARKET);
url.searchParams.set('fields', fieldList.join(','));
url.searchParams.set('ut', 'b2884a393a59ad64002292a3e90d46a5');
const resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
if (!resp.ok) throw new CliError('HTTP_ERROR', `money-flow failed: HTTP ${resp.status}`);
const data = await resp.json();
const diff = Array.isArray(data?.data?.diff) ? data.data.diff : [];
if (diff.length === 0) throw new CliError('NO_DATA', 'eastmoney returned no money-flow data');
return diff.slice(0, limit).map((it, i) => ({
rank: i + 1,
code: it.f12,
name: it.f14,
price: it.f2,
changePercent: it.f3,
mainNet: it[range.fields.net],
mainNetRatio: it[range.fields.netPct],
superNet: it[range.fields.super],
bigNet: it[range.fields.big],
mediumNet: it[range.fields.medium],
smallNet: it[range.fields.small],
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Check whether the current date is a Chinese trading day — flow rankings are empty outside trading sessions.
- Verify the range argument maps to a valid RANGES fid (INVALID_ARGUMENT would have fired otherwise, but a wrong-but-accepted key can yield empty payloads).
- Log or curl the raw response body and inspect data.data to see whether the envelope changed or is genuinely empty.
- If the envelope changed, update the extraction path `data?.data?.diff` to match the current schema.
- Retry during market hours or shortly after close when flow data is populated.
Example fix
// before
const diff = Array.isArray(data?.data?.diff) ? data.data.diff : [];
if (diff.length === 0) throw new CliError('NO_DATA', 'eastmoney returned no money-flow data');
// after — surface the envelope shape to aid diagnosis
const diff = Array.isArray(data?.data?.diff) ? data.data.diff : [];
if (diff.length === 0) {
console.error('money-flow envelope keys:', Object.keys(data ?? {}), 'data:', JSON.stringify(data?.data)?.slice(0, 200));
throw new CliError('NO_DATA', 'eastmoney returned no money-flow data');
} Defensive patterns
Strategy: fallback
Validate before calling
// Only expect data during/after trading sessions on weekdays
const now = new Date();
const day = now.getUTCDay();
const utc8Hour = (now.getUTCHours() + 8) % 24;
if (day === 0 || day === 6 || utc8Hour < 10) console.warn('Market likely closed or pre-open; empty money-flow data is likely'); Type guard
function hasDiff(data) { return Array.isArray(data?.data?.diff) && data.data.diff.length > 0; } Try / catch
try {
const rows = await runMoneyFlow({ range });
} catch (err) {
if (err instanceof CliError && err.code === 'NO_DATA') {
console.warn('No money-flow rows (market closed or schema change); using last cached snapshot');
return readCachedSnapshot();
}
throw err;
} Prevention
- Run money-flow queries during trading hours or shortly after close on trading days.
- Cache the last successful snapshot so NO_DATA can fall back to stale-but-useful data.
- Inspect the raw response envelope when NO_DATA recurs — it often signals an API schema change.
- Treat NO_DATA as a warning-level condition in scripts, not a crash.
- Confirm the range argument maps to a supported RANGES fid before invoking.
When it happens
Trigger: Querying when `data.data.diff` is missing: a non-trading day/period where no A-share flow ranking exists, eastmoney returning a success envelope with a null data object (e.g. {data:null} for an unrecognized fs/fid combination), or an API schema change renaming the diff array.
Common situations: Running on weekends or Chinese market holidays; a request whose fid (from the range argument) or fs market filter no longer matches what the API accepts, yielding a silent empty payload; eastmoney quietly changing the JSON envelope so diff moves elsewhere; off-hours runs before flow data is computed.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8e8e8b3b07daa880.
Report an issue: GitHub.