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

@deepxx/stock-tracker-sdk

v0.1.1

Published

A provider-agnostic TypeScript SDK for tracking detailed single-stock market data.

Readme

@deepxx/stock-tracker-sdk

单只 A 股交易信息追踪 SDK。它把证券代码、最新行情、分钟/日周月 OHLCV、成交额、复权和均线指标封装成稳定的 TypeScript 接口。

使用

import { StockTrackerClient } from '@deepxx/stock-tracker-sdk'

const client = new StockTrackerClient()

const snapshot = await client.getSnapshot('600519', {
  intradayInterval: '1m',
  intradayLimit: 240,
  dailyLimit: 120,
  dailyAdjustment: 'forward',
  maPeriods: [5, 10, 20, 60],
  volumeMaPeriods: [5, 10],
  dailyCacheTtlMs: 5 * 60_000,
})

console.log(snapshot.quote.price)
console.log(snapshot.intraday.candles.at(-1))
console.log(snapshot.indicators.priceMa[5].latest)
console.log(snapshot.indicators.priceMa[10].latest)
console.log(snapshot.dataQuality.dailyProvider)
console.log(snapshot.dataQuality.dailyCacheStatus)

持续追踪使用异步迭代器,并通过 AbortSignal 停止:

const controller = new AbortController()

for await (const snapshot of client.track('SH:600519', {
  pollIntervalMs: 15_000,
  signal: controller.signal,
})) {
  console.log(snapshot.generatedAt, snapshot.quote.price)
}

也可以只取某一组数据:

await client.getQuote('SZ000001')
await client.getCandles('000001', { interval: '5m', limit: 240 })
await client.getCandles('000001', { interval: '1d', adjustment: 'forward', limit: 250 })

支持范围

  • 证券代码:沪深 A 股,支持 600519、SH600519、SH:600519、1.600519 等格式。
  • 最新行情:价格、涨跌、开高低昨收、成交量、成交额、振幅、换手率、量比、PE/PB、市值等。
  • K 线:1/5/15/30/60 分钟,日、周、月;包含 OHLCV、成交额、振幅、涨跌幅、换手率。
  • 复权:不复权、前复权、后复权。
  • 指标:价格 SMA 和成交量 SMA,默认提供 MA5、MA10、MA20、MA60 与成交量 MA5、MA10。
  • 追踪:默认 15 秒轮询,可通过 AbortSignal 终止。
  • 日 K 稳定性:默认缓存 5 分钟;东方财富历史接口失败时自动切换腾讯行情,刷新失败时可使用 24 小时内的上次成功数据。

当前报价和分钟 K 默认使用东方财富公开行情接口,日/周/月 K 在东方财富不可用时自动切换腾讯行情。这里的“实时”是近实时网络行情,不是交易所授权逐笔数据;成交量原始单位为“手”,SDK 同时提供按 A 股一手 100 股换算的 volumeShares。腾讯备用历史数据不提供逐日成交额,因此对应 K 线的 amount 为 null。浏览器直连还可能受数据源 CORS 或限流影响,生产环境建议由自己的服务端调用,并用 transport 注入代理、认证和可观测性。

默认会在空响应或瞬时网络错误时对每个主机重试 2 次,再切换备用主机;可通过 retryAttempts 和 retryDelayMs 调整。

自定义数据源或网络层

构造函数可注入 StockDataProvider,从而替换行情提供方;也可只注入 JsonTransport:

const client = new StockTrackerClient({
  transport: async (url, { signal } = {}) => {
    const response = await fetch(`/api/market-data?url=${encodeURIComponent(url)}`, { signal })
    if (!response.ok) throw new Error(`HTTP ${response.status}`)
    return response.json()
  },
})

发布到 npm

包名为 @deepxx/stock-tracker-sdk,当前版本为 0.1.1。包保留 @deepxx 作用域,但发布访问级别为 public,不需要 npm 私有包订阅。

确认当前 npm 账号拥有 @deepxx 作用域的发布权限,然后从包目录执行:

cd packages/stock-tracker-sdk
npm login --registry=https://registry.npmjs.org
pnpm run publish:public

publish:public 会先自动执行完整测试和构建,再以公开 scoped package 发布;它使用包目录下的临时 npm cache,以绕过本机全局 npm cache 的权限问题。

如果使用 token,请只写入用户级 ~/.npmrc 或 CI Secret,不要提交到仓库。后续版本发布前先更新版本号,例如:

npm version patch --no-git-tag-version

消费端直接安装:

npm install @deepxx/stock-tracker-sdk