Skip to content

Batch Query

Efficiently fetch large amounts of stock data.

getAllAShareQuotes

Get all A-Share real-time quotes. Supports filtering by exchange or board.

typescript
// Get all A-Share quotes
const quotes = await sdk.getAllAShareQuotes();

// Get STAR Market (科创板) quotes only
const kcQuotes = await sdk.getAllAShareQuotes({ market: 'kc' });

// Get ChiNext (创业板) quotes with progress
const cyQuotes = await sdk.getAllAShareQuotes({
  market: 'cy',
  batchSize: 500,
  concurrency: 5,
  onProgress: (completed, total) => {
    console.log(`Progress: ${completed}/${total}`);
  },
});

Parameters

ParameterTypeDefaultDescription
marketAShareMarket-Filter by exchange/board
batchSizenumber500Codes per request
concurrencynumber7Parallel requests
onProgressfunction-Progress callback

AShareMarket Type

ValueDescriptionCode Pattern
'sh'Shanghai Stock ExchangeStarts with 6
'sz'Shenzhen Stock ExchangeStarts with 0 or 3
'bj'Beijing Stock ExchangeStarts with 92
'kc'STAR Market (科创板)Starts with 688
'cy'ChiNext (创业板)Starts with 30

getAllHKShareQuotes

Get all HK stock quotes.

typescript
const quotes = await sdk.getAllHKShareQuotes({
  concurrency: 5,
  onProgress: (c, t) => console.log(`${c}/${t}`),
});

getAllUSShareQuotes

Get all US stock quotes. Supports filtering by market.

Parameters

ParameterTypeDefaultDescription
batchSizenumber500Batch size per request
concurrencynumber7Max concurrent requests
onProgressfunction-Progress callback
marketUSMarket-Filter by market: NASDAQ, NYSE, AMEX

Example

typescript
// Get all US stocks
const allQuotes = await sdk.getAllUSShareQuotes();

// Get NASDAQ stocks only
const nasdaqQuotes = await sdk.getAllUSShareQuotes({ market: 'NASDAQ' });

// Get NYSE stocks with progress
const nyseQuotes = await sdk.getAllUSShareQuotes({
  market: 'NYSE',
  concurrency: 5,
  onProgress: (c, t) => console.log(`${c}/${t}`),
});

getAllQuotesByCodes

Get quotes for specific code list.

typescript
const codes = ['sh600000', 'sz000001', 'sh600519', ...];

const quotes = await sdk.getAllQuotesByCodes(codes, {
  batchSize: 100,
  concurrency: 3,
});

batchRaw

Low-level batch query for mixed data types.

typescript
const result = await sdk.batchRaw([
  'r_sz000858',  // Real-time quote
  'r_sh600519',  // Real-time quote
]);

Performance Tips

  1. Adjust concurrency based on network

    • Low latency: Use higher concurrency (7-10)
    • High latency: Use lower concurrency (3-5)
  2. Use progress callbacks for UI feedback

    typescript
    onProgress: (completed, total) => {
      updateProgressBar(completed / total * 100);
    }
  3. Handle errors gracefully

    typescript
    try {
      const quotes = await sdk.getAllAShareQuotes();
    } catch (error) {
      // Implement retry or fallback
    }

Released under the ISC License.