Skip to content

US Stock Quotes

Get real-time quotes for US stocks.

getUSQuotes

typescript
const quotes = await sdk.getUSQuotes(['AAPL', 'MSFT', 'BABA']);

Parameters

ParameterTypeRequiredDescription
codesstring[]YesUS stock tickers

Return Type

typescript
interface USQuote {
  code: string;           // Stock code
  name: string;           // Stock name
  price: number;          // Current price (USD)
  change: number;         // Price change
  changePercent: number;  // Change percentage
  volume: number;         // Trading volume
  amount: number;         // Trading amount
  high: number;           // Day high
  low: number;            // Day low
  open: number;           // Open price
  prevClose: number;      // Previous close
  time: string;           // Quote time
  high52w: number;        // 52-week high
  low52w: number;         // 52-week low
  pe: number;             // P/E ratio
  marketCap: number;      // Market cap
}

getUSHistoryKline

Get US stock historical K-line data.

typescript
// Note: Use market.ticker format for K-line
const klines = await sdk.getUSHistoryKline('105.MSFT', {
  period: 'daily',
  startDate: '20240101',
  endDate: '20241231',
});

Parameters

ParameterTypeRequiredDescription
codestringYesUS stock code (market.ticker)
options.period'daily' | 'weekly' | 'monthly'NoK-line period (default: daily)
options.startDatestringNoStart date (YYYYMMDD)
options.endDatestringNoEnd date (YYYYMMDD)
options.adjust'' | 'qfq' | 'hfq'NoAdjust type (default: hfq)

Market Codes

CodeMarket
105NASDAQ
106NYSE
107Other

getAllUSShareQuotes

Get all US stock quotes.

typescript
const allQuotes = await sdk.getAllUSShareQuotes({
  concurrency: 5,
  onProgress: (completed, total) => {
    console.log(`Progress: ${completed}/${total}`);
  },
});

Example

typescript
import { StockSDK } from 'stock-sdk';

const sdk = new StockSDK();

// Get US stock quotes
const quotes = await sdk.getUSQuotes(['AAPL', 'MSFT', 'GOOGL', 'BABA']);
quotes.forEach(q => {
  console.log(`${q.name}: USD ${q.price} (${q.changePercent}%)`);
});
// Apple Inc.: USD 180.00 (1.20%)
// Microsoft Corp.: USD 380.00 (0.80%)

// Get US stock K-line
const klines = await sdk.getUSHistoryKline('105.AAPL', {
  period: 'daily',
  startDate: '20240101',
});
console.log(`Got ${klines.length} K-line records`);

Released under the ISC License.