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

@litou.cjs/stock-data-downloader

v0.1.0

Published

Download Chinese A-share financial reports (annual, semi-annual, quarterly) | 下载 A 股上市公司财务报告

Downloads

566

Readme

Stock Data Downloader | A股财务报告下载工具

npm version npm downloads Node.js Version

一个命令行工具,用于批量下载 A 股上市公司的财务报告(年报、半年报、季报)。

功能特性

  • 多种报告类型: 支持年报、半年报、季报下载
  • 🔍 智能搜索: 支持股票代码、公司名称、拼音模糊匹配
  • 并发下载: 可配置并发数,默认 3 个并发
  • 🔄 自动重试: 失败自动重试,支持指数退避
  • 📊 进度显示: 实时进度条显示下载状态
  • 📝 日志记录: 支持控制台和文件双路日志输出
  • 文件验证: 自动验证 PDF 文件完整性
  • 🚫 去重处理: 自动跳过已下载的文件

安装

npm install -g @litou.cjs/stock-data-downloader

快速开始

交互式模式

stock-data-downloader

程序会提示你输入股票代码或公司名称,然后展示匹配结果供选择。

命令行模式

# 下载贵州茅台最近10年的报告
stock-data-downloader --stock 600519

# 下载平安银行最近5年的报告
stock-data-downloader --stock 平安银行 --years 5

# 指定输出路径和并发数
stock-data-downloader --stock 600519 --output ./reports --concurrency 5

# 详细日志模式
stock-data-downloader --stock 600519 --verbose

命令行选项

Options:
  -s, --stock <code>         股票代码或公司名称
  -y, --years <number>       下载年份数量 (默认: 10)
  -o, --output <path>        输出路径 (默认: ./downloads)
  -c, --concurrency <number> 并发下载数 (默认: 3)
  --timeout <ms>             超时时间(毫秒) (默认: 30000)
  -v, --verbose              详细日志模式
  -V, --version              显示版本号
  -h, --help                 显示帮助信息

输出文件结构

downloads/
└── 600519_贵州茅台/
    ├── 600519_贵州茅台_2023_年报.pdf
    ├── 600519_贵州茅台_2023_半年报.pdf
    ├── 600519_贵州茅台_2023_Q1报.pdf
    ├── 600519_贵州茅台_2023_Q3报.pdf
    ├── 600519_贵州茅台_2022_年报.pdf
    └── ...

数据源

  • 主数据源: 巨潮资讯网 (cninfo.com.cn)
  • 官方、权威、完整的 A 股上市公司公告数据

开发

项目结构

src/
├── cli/              # CLI 入口和命令行处理
│   └── index.ts
├── core/             # 核心逻辑
│   ├── downloader.ts # 下载引擎(并发、重试、进度)
│   └── fuzzySearch.ts # 模糊搜索功能
├── datasources/      # 数据源实现
│   └── cninfo.ts     # 巨潮资讯网接口
├── utils/            # 工具函数
│   ├── logger.ts     # 日志系统
│   ├── progress.ts   # 进度条
│   └── fileUtils.ts  # 文件工具
└── types/            # TypeScript 类型定义
    └── index.ts

技术栈

  • 语言: TypeScript
  • 运行时: Node.js >= 18.0.0
  • 主要依赖:
    • axios: HTTP 请求
    • commander: CLI 框架
    • inquirer: 交互式命令行
    • p-queue: 并发控制
    • cli-progress: 进度条
    • winston: 日志系统
    • pinyin-pro: 拼音转换
    • fs-extra: 文件操作

常见问题

Q: 为什么有些报告下载失败?

A: 可能的原因:

  1. 网络不稳定:程序会自动重试3次
  2. 数据源限流:程序内置了速率限制机制
  3. 文件不存在:部分公司某些季度可能未发布报告

Q: 支持哪些股票市场?

A: 当前版本仅支持 A 股(上交所、深交所)。未来版本计划支持港股和美股。

Q: 如何处理重复下载?

A: 程序会自动检查文件是否已存在,已存在的文件会被跳过。

License

MIT

Author

陈建生

Changelog

v0.1.0 (2026-03-25)

  • 初始 MVP 版本发布
  • 支持 A 股年报、半年报、季报下载
  • 实现模糊搜索功能
  • 支持并发下载和自动重试