Stock SDK is a zero-dependency JavaScript/TypeScript SDK for frontend and Node.js to fetch real-time stock data (A-share, HK, US, funds) in-browser or server, with CLI and MCP server support.
Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).
What it is
Stock SDK is a JavaScript/TypeScript library intended for frontend and Node.js environments to fetch stock data without Python or backend services. It supports real-time行情 and K-line data for A-share, HK, US stocks, and mutual funds, and includes a command-line interface (CLI) and an MCP server.
How it works
The SDK exposes namespace-based APIs (e.g., sdk.quotes.cn(), sdk.kline.withIndicators(), sdk.batch.cn()) and provides a unified symbol model. It offers zero dependencies, browser and Node.js compatibility, ES Module and CommonJS support, and a built-in MCP server for AI tool integration. It includes a provider governance mechanism with retry, rate limiting, and the option to inject a custom fetch implementation. It also supports subpath imports for pure computation (indicators, symbols, signals, screener) to avoid loading network providers.
Getting started
Install via npm:
# 最新版(v2:命名空间 API / CLI / MCP)
npm install stock-sdk
# v1 旧版(已封存,仅维护 critical 修复)
npm install stock-sdk@legacy
示例用法
import { StockSDK } from 'stock-sdk';
const sdk = new StockSDK();
// 命名空间 API(v2)
const quotes = await sdk.quotes.cnSimple(['sh000001', 'sz000858', 'sh600519']);
// 历史 K 线 + 指标
const kline = await sdk.kline.withIndicators('600519', {
period: 'daily',
indicators: { ma: { periods: [5, 10, 20] }, macd: {} },
});
// 全市场行情
const all = await sdk.batch.cn({ concurrency: 5 });
CLI 使用示例
npx stock-sdk quote 600519 00700 AAPL
npx stock-sdk kline 600519 --period weekly --limit 30
npx stock-sdk indicators 600519 --ma 5,10,20 --macd
AI / MCP 集成
npx stock-sdk mcp
Recent releases
- v2.4.1 (2026-08-02): Removal of fund.estimate due to upstream outage; breaking change but not affecting functioning code.
- v2.4.0 (2026-07-12): Hardening and feature additions including MCP Skills, get_kline_signals, and new tools for large orders / margin financing.
- v2.3.0 (2026-07-07): Added chips distribution and per-stock market changes; minor non-breaking API changes noted in behavior.
- v2.2.2 (2026-07-04): Indicator precision increased to 3 decimals with decimals option.
- v2.2.1 (2026-07-03): Support for东方财富特殊指数 and related inputs.
Traction
- Stars: 1791
- Forks: 165
- Open issues: 3
License
ISC
开发/运行校验
- Development and tests use pnpm typecheck, build, test, and integration tests as listed in the repository.
备注
- Data latency: Real-time data is from public interfaces (Tencent Finance / Eastmoney), not real-time matching, with typical delays.






