Skip to content

sdk.quotes · Real-time Quotes

The sdk.quotes namespace provides real-time / snapshot quotes per market: A-share full and simple, HK, US, fund, plus fund flow (simple), large orders and intraday timeline.

ts
import { StockSDK } from 'stock-sdk'

const sdk = new StockSDK()
const list = await sdk.quotes.cn(['600519', '000001'])

Methods

MethodDescription
quotes.cn(codes)A-share full quotes (five-level bid/ask, turnover rate, PE/PB, limit-up/down, etc.)
quotes.cnSimple(codes)A-share simple quotes (trimmed fields, cheaper)
quotes.hk(codes)HK quotes
quotes.us(codes)US quotes
quotes.fund(codes)Fund quotes (unit NAV / accumulated NAV)
quotes.fundFlow(codes)Fund flow (simple, Tencent source)
quotes.largeOrder(codes)Large orders
quotes.timeline(code)Intraday timeline

quotes.fundFlow vs sdk.fundFlow.*: the former is the simple fund flow (Tencent source, returned with the quote snapshot); the latter is the deep fund flow (Eastmoney source, with individual / market / rank / sector history). They differ in source and dimensions — see fundFlow.

Examples

A-share quotes

ts
// Input is an array of codes; symbol forms are lenient: bare / prefixed / secid
const quotes = await sdk.quotes.cn(['600519', 'sh601318', '000001'])

for (const q of quotes) {
  console.log(q.name, q.price, q.changePercent)
}

A-share simple quotes

ts
// Fewer fields, cheaper — good for polling watchlists / market boards
const simple = await sdk.quotes.cnSimple(['600519', '000858'])

HK / US

ts
const hk = await sdk.quotes.hk(['00700', '09988']) // 5-digit → HK
const us = await sdk.quotes.us(['AAPL', 'TSLA']) // pure letters → US

Fund

ts
const fund = await sdk.quotes.fund(['161725'])
console.log(fund[0].nav, fund[0].accNav) // unit NAV / accumulated NAV

Large orders / intraday timeline

ts
const orders = await sdk.quotes.largeOrder(['600519'])
const timeline = await sdk.quotes.timeline('600519') // single code

Return: the Quote discriminated union

A-share / HK / US / fund quotes return a union discriminated by assetType named Quote. Narrow with switch first, then access market-specific fields:

ts
const [q] = await sdk.quotes.cn(['600519'])

switch (q.assetType) {
  case 'stock':
    console.log(q.bid, q.ask, q.turnoverRate, q.pe) // A-share specific
    break
  case 'fund':
    console.log(q.nav, q.accNav) // fund specific
    break
}

Base fields (shared by all quotes)

FieldTypeDescription
symbolstringNormalized standard symbol
codestringBare code (no prefix, e.g. 600519)
namestringName
market'CN' | 'HK' | 'US' | 'GLOBAL'Trading region
assetType'stock' | 'fund' | ...Asset type (union discriminant)
exchangestringExchange (e.g. SSE / HKEX / NASDAQ)
currencystringISO quote currency (CNY / HKD / USD); determines the unit of amounts / prices below
sourcestringData source (tencent / eastmoney / sina)
timestringRaw time string (market timezone)
timestampnumber | nullUTC ms; null when unparseable
tzMarketTzMarket timezone

Quote fields (stock-type)

FieldTypeDescription
pricenumberCurrent price (current beta follows the provider's raw convention)
prevClose / open / high / lownumberPrev close / open / high / low
changenumberChange amount
changePercentnumberChange percent (percentage number, e.g. 5.2)
volumenumberVolume (current beta follows the provider's raw convention)
amountnumberTurnover (current beta follows the provider's raw convention)

A-share (StockQuote) additionally carries five-level bid / ask, turnoverRate, pe, pb, limitUp, limitDown, etc.; HK carries lotSize; US carries pe / pb. Funds (FundQuote) carry nav / accNav / change / changePercent.

Unit conventions

  • Percentages are percentage numbers (5.2 means 5.2%, not 0.052).
  • Amounts / prices target each market's base quote currency (CN = CNY / HK = HKD / US = USD), indicated by currency, with no cross-currency conversion.
  • Volume targets the shares unit.
  • The current beta has not completed per-source unit calibration, so runtime values still follow each provider's raw convention (for example, Tencent A-share volume is lots and turnover is in 10k CNY).
  • Invalid timestamps are null (no longer NaN).
  • The raw field is removed; for debugging raw payloads, use the provider-level getXxxRaw().

Fields are subject to the implementation. The full field list is finalized along with src/sdk/namespaces/quotesNs.ts and the type definitions.