npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stock-sdk

v1.7.0

Published

Tencent qt.gtimg.cn stock quote SDK - supports both browser and Node.js

Readme

Stock SDK

npm version npm downloads license Test Coverage

English | 中文

前端和 Node.js 设计的股票行情 JavaScript SDK

无需 Python、无需后端服务,直接在 浏览器或 Node.js 中获取 A 股 / 港股 / 美股 / 公募基金 的实时行情与 K 线数据。

✨ 零依赖 | 🌐 Browser + Node.js | 📦 <20KB | 🧠 完整 TypeScript 类型

Documentation

👉🏻 官方文档

📦 NPM | 📖 GitHub | 🎮 在线演示

🧭 Stock Dashboard:基于 stock-sdk 搭建的股票数据大盘演示站点,欢迎体验。

Why stock-sdk?

如果你是前端工程师,可能遇到过这些问题:

  • 股票行情工具大多是 Python 生态,前端难以直接使用
  • 想做行情看板 / Demo,不想额外维护后端服务
  • 财经接口返回格式混乱、编码复杂(GBK / 并发 / 批量)
  • AkShare 很强,但并不适合浏览器或 Node.js 项目

stock-sdk 的目标很简单:

让前端工程师,用最熟悉的 JavaScript / TypeScript,优雅地获取股票行情数据。


使用场景

  • 📊 股票行情看板(Web / Admin)
  • 📈 数据可视化(ECharts / TradingView)
  • 🎓 股票 / 金融课程 Demo
  • 🧪 量化策略原型验证(JS / Node)
  • 🕒 Node.js 定时抓取行情数据

特性

  • 零依赖,轻量级(压缩后 < 20KB)
  • ✅ 支持 浏览器Node.js 18+ 双端运行
  • ✅ 同时提供 ESMCommonJS 两种模块格式
  • ✅ 完整的 TypeScript 类型定义和单元测试覆盖
  • A 股、港股、美股、公募基金实时行情
  • 历史 K 线(日/周/月)、分钟 K 线(1/5/15/30/60 分钟)和当日分时走势数据
  • 技术指标:内置 MA、MACD、BOLL、KDJ、RSI、WR 等常用指标计算
  • 期货行情:国内期货 K 线、全球期货实时行情与 K 线、期货库存数据
  • 资金流向盘口大单等扩展数据
  • ✅ 获取全部 A 股代码列表(5000+ 只股票)和批量获取全市场行情(内置并发控制)

安装

npm install stock-sdk
# 或
yarn add stock-sdk
# 或
pnpm add stock-sdk

快速开始(10 行 Demo)

import { StockSDK } from 'stock-sdk';

const sdk = new StockSDK();

const quotes = await sdk.getSimpleQuotes([
  'sh000001',
  'sz000858',
  'sh600519',
]);

quotes.forEach(q => {
  console.log(`${q.name}: ${q.price} (${q.changePercent}%)`);
});

示例:全市场 A 股行情

前端直接一次性获取全市场 A 股行情(5000+股票),无需 Python 或后端服务。

const allQuotes = await sdk.getAllAShareQuotes({
  batchSize: 300,
  concurrency: 5,
  onProgress: (completed, total) => {
    console.log(`进度: ${completed}/${total}`);
  },
});

console.log(`共获取 ${allQuotes.length} 只股票`);

API 列表

💡 API 详细文档请查阅 https://stock-sdk.linkdiary.cn/

实时行情

| 方法 | 说明 | |------|------| | getFullQuotes | A 股/指数全量行情 | | getSimpleQuotes | A 股/指数简要行情 | | getHKQuotes | 港股行情 | | getUSQuotes | 美股行情 | | getFundQuotes | 公募基金行情 |

K 线数据

| 方法 | 说明 | |------|------| | getHistoryKline | A 股历史 K 线(日/周/月) | | getHKHistoryKline | 港股历史 K 线(日/周/月) | | getUSHistoryKline | 美股历史 K 线(日/周/月) | | getMinuteKline | A 股分钟 K 线(1/5/15/30/60 分钟) | | getTodayTimeline | A 股当日分时走势 |

技术指标

| 方法 | 说明 | |------|------| | getKlineWithIndicators | 获取带技术指标的 K 线数据 | | calcMA | 计算均线(SMA/EMA/WMA) | | calcMACD | 计算 MACD | | calcBOLL | 计算布林带 | | calcKDJ | 计算 KDJ | | calcRSI | 计算 RSI | | calcWR | 计算威廉指标 | | calcBIAS | 计算乖离率 | | calcCCI | 计算商品通道指数 | | calcATR | 计算平均真实波幅 |

行业板块

| 方法 | 说明 | |------|------| | getIndustryList | 行业板块名称列表 | | getIndustrySpot | 行业板块实时行情 | | getIndustryConstituents | 行业板块成分股 | | getIndustryKline | 行业板块历史 K 线(日/周/月) | | getIndustryMinuteKline | 行业板块分时行情(1/5/15/30/60 分钟) |

概念板块

| 方法 | 说明 | |------|------| | getConceptList | 概念板块名称列表 | | getConceptSpot | 概念板块实时行情 | | getConceptConstituents | 概念板块成分股 | | getConceptKline | 概念板块历史 K 线(日/周/月) | | getConceptMinuteKline | 概念板块分时行情(1/5/15/30/60 分钟) |

期货行情

| 方法 | 说明 | |------|------| | getFuturesKline | 国内期货历史 K 线(日/周/月) | | getGlobalFuturesSpot | 全球期货实时行情 | | getGlobalFuturesKline | 全球期货历史 K 线(日/周/月) | | getFuturesInventorySymbols | 期货库存品种列表 | | getFuturesInventory | 期货库存数据 | | getComexInventory | COMEX 黄金/白银库存 |

扩展数据

| 方法 | 说明 | |------|------| | getFundFlow | 资金流向 | | getPanelLargeOrder | 盘口大单占比 | | getTradingCalendar | A 股交易日历 |

批量查询

| 方法 | 说明 | |------|------| | getAShareCodeList | 获取全部 A 股代码 | | getUSCodeList | 获取全部美股代码 | | getHKCodeList | 获取全部港股代码 | | getAllAShareQuotes | 获取全市场 A 股行情 | | getAllHKShareQuotes | 获取全市场港股行情 | | getAllUSShareQuotes | 获取全市场美股行情 | | getAllQuotesByCodes | 批量获取指定股票行情 |

搜索

| 方法 | 说明 | |------|------| | search | 搜索股票代码/名称/拼音 |


许可证

ISC


🌐 官网 | 📦 NPM | 📖 GitHub | 🎮 在线演示 | 🧭 Stock Dashboard | 🐛 Issues


如果这个项目对你有帮助,欢迎 Star ⭐ 或提出 Issue 反馈。