Stock SDK
A zero-dependency JavaScript SDK for frontend and Node.js to fetch stock data for A-shares, HK, US, and funds, with CLI and MCP server included.
- Source repo
- chengzuopeng/stock-sdk
- Stars
- ★ 2k
- Last updated
- 16d ago
- License
- ISC
- Primary language
- TypeScript
- FA score
- 71/100 · Some gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformChatGPT · Codex · Claude Code
- Cost
- Free, no paid service needed
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- Frontend engineers building a stock dashboard or data visualization page who want to avoid maintaining a backend service or using Python.
- Not a fit if
- Teams needing high-frequency trading or real-time matching quotes
- Projects built on Python or requiring a backend service
- Users needing full minute-level futures and options data
- Source review
- 71/100 · Some gaps 1 safety controls not found
What does this agent do, and when should you use it?
Stock SDK is a zero-dependency JavaScript/TypeScript library for frontend and Node.js environments to retrieve real-time quotes and K-line data for A-shares, Hong Kong, US stocks, and public funds. It offers a namespaced API with tolerant symbol parsing, technical indicators, chip distribution, signal detection, screening, and backtesting. It provides a CLI (stock-sdk command) and a built-in MCP server for AI integration, supporting ESM, CommonJS, and subpath exports for tree-shaking. v2.0.0 is an architectural upgrade introducing namespaced APIs and a unified error system, but includes breaking changes. Data is sourced from public APIs like Tencent Finance and Eastmoney, with latency unsuitable for high-frequency trading.
Stock SDK fetches and parses stock market data from public APIs such as Tencent Finance and Eastmoney. It handles symbol normalization (e.g., sh600519, 600519.SH, 00700, AAPL), provides real-time quotes (sdk.quotes.cn()), K-line (sdk.kline.cn()), minute bars, intraday timelines, technical indicator calculations (MA, MACD, BOLL, etc.), chip distribution, fund flows, and dragon-tiger lists. Users can call these via namespaced async APIs in Node.js or browser, use the CLI (e.g., stock-sdk quote 600519), or start the built-in MCP server (npx stock-sdk mcp) to expose tools to AI clients like Cursor or Claude. Pure-computation subpath imports (stock-sdk/indicators) are also available for indicator and signal math.
- Frontend engineers building a stock dashboard or data visualization page who want to avoid maintaining a backend service or using Python.
- Developers needing to periodically fetch stock quotes in Node.js for quantitative strategy prototyping or analysis.
- Command-line users who want to quickly check a stock's price or K-line without writing a full application.
- Users of AI tools like Cursor or Claude who want the assistant to access stock data via the MCP server.
- Educators or students in finance courses who need a simple JavaScript library to demonstrate live market data.
How do you install or deploy this agent?
Install via npm: npm install stock-sdk. For the v1 legacy version, use npm install stock-sdk@legacy. Requires Node.js 18+. No API keys or credentials are needed.
How do you use this agent?
After installation, import the SDK and create an instance: import { StockSDK } from 'stock-sdk'; const sdk = new StockSDK(); Then call namespaced APIs, e.g., fetch A-share quotes: await sdk.quotes.cnSimple(['sh000001', 'sz000858', 'sh600519']). For CLI, use npx stock-sdk quote 600519. For MCP integration, run npx stock-sdk mcp to start the server, and configure mcpServers in your client.
What are this agent's strengths and limitations?
- Zero dependencies, works in both browser and Node.js, simplifying integration.
- Includes a CLI and built-in MCP server, enabling command-line use and AI integration.
- Full TypeScript types, rich namespaced API, and IDE autocompletion friendly.
- Subpath exports allow importing pure computation modules to keep bundles lean.
- Data comes from public APIs, not real-time matching, with latency unsuitable for high-frequency trading.
- v2 is a breaking change; migrating from v1 requires reading the guide, no compatibility aliases.
- Market coverage varies; futures and options have limited functionality, observe the support matrix.
- Relies on upstream API stability; provider changes may require SDK updates.
How does this agent compare with similar options?
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Stock SDK This agent | 71 · Some gaps | Library / SDKFree | ★ 2k | 16d ago | TypeScript | ChatGPT · Codex · Claude Code |
| Unbrowse Website API Client | 56 · Major gaps | Hosted serviceFreemium | ★ 801 | 1d ago | TypeScript | ChatGPT · Codex · Claude Code |
| Superset | 52 · Major gaps | Desktop appFreemium | ★ 15k | today | TypeScript | Codex · Claude Code |
| OSS Autopilot | 83 · Good | Agent plugin / skillFree | ★ 21 | 1d ago | TypeScript | Claude Code · Claude.ai |
How does FollowAgents rate this agent?
Why each dimension lost points
Evidence: SDK is a pure client library, no backend, minimal permissions (least_privilege=2). No user confirmation mechanism (user_confirmation=0). Data flow transparent: docs state data sources are public Tencent/Eastmoney APIs and note latency (data_flow_transparency=2). Sensitive data handling: no collection/transmission of sensitive data found, but no explicit statement (sensitive_data_handling=1). Dependency security: zero runtime dependencies, devDependencies no known vulnerabilities (dependency_security=2). External effects: only network requests for public data, no destructive actions (external_effects=2). Rollback: v1 migration guide provided, but no automatic rollback (rollback=1). Source attribution: author and repo clear, but publisher unverified (source_attribution=2).
Evidence: Code structure consistent, namespace API unified (self_consistency=2). Dependency availability: zero runtime deps, devDependencies pinned (dependency_availability=2). Failure messages: unified error system with SdkError and codes (failure_messages=2).
Evidence: Clear target audience (frontend engineers), scenarios cover dashboards, visualization, education (audience_and_scenarios=3). Capability boundaries clear: market support matrix details capabilities per market (capability_boundaries=3). Trigger precision: API design precise, symbol parsing tolerant (trigger_precision=2). Environment fit: supports browser and Node.js 18+, ESM/CJS (environment_fit=3).
Evidence: Clear information architecture, namespace grouping (information_architecture=3). Install notes detailed (install_notes=3). Naming stability: v2 breaking changes but migration guide provided (naming_stability=2). Examples and FAQ: README provides many examples, official docs (examples_and_faq=3). Known limitations: data latency and unsupported markets noted (known_limitations=2). License: ISC clear (license=3). Versioning/changelog: version number present, but no CHANGELOG file (versioning_changelog=2). Maintenance responsibility: author clear, but unverified (maintenance_responsibility=2).
Evidence: Output formats unified, supports JSON/CSV/table (output_usability=3). Marginal value: provides zero-dependency stock data solution for frontend, fills gap (marginal_value=3). Cost-benefit: zero-dependency, lightweight, free (cost_benefit=3).
Evidence: Claims in README supported by code and tests (claim_traceability=2). Cross-source corroboration: relies on single data source, no comparison with others (cross_source_corroboration=1). Fact/inference separation: docs distinguish data sources and local calculations (fact_inference_separation=2).
- Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
- Publisher identity unverified; assess risk before use.
- Data from third-party public APIs may have latency or instability; not suitable for high-frequency trading.
- No CHANGELOG file provided; version history incomplete.
- No explicit statement on user data collection; review code if concerned.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
v2.4.6 v2.4.6 K-line Fallback Switch
Release notes excerpt
v2.4.6 是一次 请求可控 + 数据正确性 版本:A 股 K 线的备用源切换可以关闭了,批量拉取时不必再连带触发备用源的频控;同时修掉 chips.cn 在备用源下静默返回空统计的问题。无破坏性变更,升级无需改代码。 新增 - A 股 K 线备用源开关 klineFallback(#80,感谢 @zhrenyue 提出需求):2.4.4 起,A 股 K 线在东方财富失败时会按腾讯、新浪顺序切换,但没法关掉。批量拉取时东财一旦频控,每只股票都会转去请求腾讯(长历史要分页请求多次)和新浪,备用源随之也被频控。现在可以关闭: ```ts const sdk = new StockSDK({ klineFallback: false, providerPolicies: { eastmoney: { rateLimit: { requestsPerSecond: 2 }, // 控制节奏,减少软限流 retry: { maxRetries: 2 }, // 只覆盖断连、超时和可重试的 HTTP 状态码 }, }, }) ``` | klineFallback | 东方财富请求 | 东方财富失败时 | …View on GitHub ↗ -
v2.4.5 v2.4.5 Pagination & HK Real-time Quote Keys
Release notes excerpt
v2.4.5 是一次 取数效率 + 行情时效 版本:资金流排名与盘口异动支持分页,只看榜单前段不必再拉全量;港股个股行情改用腾讯实时行情键。无破坏性变更,升级无需改代码。 新增 - 资金流排名与盘口异动支持分页(#65,感谢 @iarjian 提出需求):此前这三个方法只能拉全量。个股资金流排名每次调用都要按每页 100 条翻完全市场约 5600 条,约 57 次请求,只想看前 20 也得全拉,放大了被东财限流的风险。 | 方法 | 新增参数 | 每页条数 | |---|---|---| | fundFlow.rank(options) | page / pageSize | 1–100,默认 100 | | fundFlow.sectorRank(options) | page / pageSize | 1–100,默认 100 | | marketEvent.stockChanges(type?, options?) | 新增第二个参数 { page, pageSize } | 1–5000,默认 100 | …View on GitHub ↗ -
v2.4.4 v2.4.4 K-line Fallback Fixes & Regulatory Alerts
Release notes excerpt
v2.4.4 是一次 上游容灾 + 数据正确性 版本:A 股 K 线在东财受限时可切换备用源,同时修掉备用源带来的前复权负价问题,并新增交易所监管异动预警接口。无破坏性变更,升级无需改代码。 新增 - 监管异动 marketEvent.unusualFluctuation(#76,感谢 @WJMA-GIT 提出需求并提供线索):交易所「股票交易异常波动」预警,能看到哪些个股已触发、哪些正在逼近阈值。 | 字段 | 说明 | |---|---| | rule | 规则原文,如「连续十个交易日内日收盘价涨跌幅偏离值累计达到+100%」 | | triggered | 是否已触发;false 表示逼近阈值但未达 | | deviationValue | 累计涨跌幅偏离值(%),与规则阈值同口径可直接比较 | | windowDays / changePercent / direction | 规则窗口天数 / 当日涨跌幅 / 异动方向 | 参数 date 查单日、startDate+endDate 查区间(两者互斥),triggered 可只看已触发或只看逼近未触发。CLI 与 MCP 工具 get_unusual_fluctuation 同步派生。 …View on GitHub ↗