← 返回 Skills 市场
xiyunnet

A股数据获取 A specialized data collection tool for Chinese A-share market

作者 小潴 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
350
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install a-stock-get
功能描述
Specialized A-share stock data collector. Automatically fetch and store daily/weekly/monthly historical K-line data for all A-share stocks in SQLite database.
使用说明 (SKILL.md)

A-Share-Get / A股数据获取工具

English | 中文


Overview / 概述

English:
A specialized data collection tool for Chinese A-share market. Automatically fetches and stores stock list, daily, weekly, and monthly historical K-line data into a local SQLite database. Designed specifically for quantitative analysts who need a complete local copy of A-share market data.

中文:
专门针对中国A股市场的数据获取工具。自动采集并存储股票列表、日线、周线、月线历史K线数据到本地SQLite数据库。专为需要完整A股本地数据副本的量化分析师设计。


Features / 功能特性

English:

  • Automated Stock List Management: Fetches and updates all tradable stocks from A-share markets (60* Shanghai, 30* ChiNext, 00* Shenzhen)
  • Multi-Frequency Data Collection: Supports parallel fetching for daily, weekly, and monthly K-line data
  • SQLite Database Storage: Local persistent storage, easy to query for quantitative analysis
  • Automatic Filtering: Excludes delisted and pre-IPO stocks automatically
  • Data Integrity: Tracks last fetch timestamp for each frequency, supports incremental updates
  • Multiple Data Sources: EastMoney/Sina/Tencent with automatic failover

中文:

  • 自动化股票列表管理: 获取并更新A股市场全部可交易股票(沪市60*、创业板30*、深市00*)
  • 多频率数据采集: 支持并行获取日线、周线、月线K线数据
  • SQLite数据库存储: 本地持久化存储,便于量化分析查询
  • 自动过滤: 自动排除退市和未上市股票
  • 数据完整性: 记录每种频率最后获取时间戳,支持增量更新
  • 多数据源冗余: 东方财富/新浪/腾讯,自动故障切换

Database Schema / 数据库架构

Stock List Table (stocks)

Column / 字段 Type / 类型 Description / 说明
code TEXT Stock code (e.g., 600519) / 股票代码
name TEXT Stock name (e.g., 贵州茅台) / 股票名称
market TEXT Market type (60/30/00) / 市场类型
day_get TIMESTAMP Last daily data fetch time / 最后日线数据获取时间
week_get TIMESTAMP Last weekly data fetch time / 最后周线数据获取时间
month_get TIMESTAMP Last monthly data fetch time / 最后月线数据获取时间
status TEXT Stock status (active/delisted) / 股票状态
created_at TIMESTAMP Record creation time / 记录创建时间

Installation & Setup / 安装与设置

Step 1: Database Initialization / 第一步:数据库初始化

English:
Run the initialization script to create the database and tables:

python scripts/init_db.py

中文:
运行初始化脚本创建数据库和表:

python scripts/init_db.py

Step 2: Fetch Stock List / 第二步:获取股票列表

English:
Fetch all tradable stocks from A-share markets:

python scripts/fetch_stocks.py

中文:
从A股市场获取所有可交易股票列表:

python scripts/fetch_stocks.py

Step 3: Start Data Collection / 第三步:启动数据收集

English:

# Enhanced data fetching with external events
python scripts/day.py get all --limit 10
python scripts/week.py get all --limit 10
python scripts/month.py get all --limit 10

# Traditional usage (fetch all active stocks)
python scripts/day.py
python scripts/week.py
python scripts/month.py

# Database reset and fetch tool
python scripts/db_reset.py reset status
python scripts/db_reset.py fetch day 000001

# Parallel fetching for large batches
python scripts/day_parallel.py
python scripts/week_parallel.py
python scripts/month_parallel.py

中文:

# 增强版数据获取(支持外部事件)
python scripts/day.py get all --limit 10
python scripts/week.py get all --limit 10
python scripts/month.py get all --limit 10

# 传统用法(获取所有活跃股票)
python scripts/day.py
python scripts/week.py
python scripts/month.py

# 数据库重置与获取工具
python scripts/db_reset.py reset status
python scripts/db_reset.py fetch day 000001

# 并行获取大量数据
python scripts/day_parallel.py
python scripts/week_parallel.py
python scripts/month_parallel.py

File Structure / 文件结构

a-stock-get/
├── SKILL.md                  # This documentation
├── scripts/
│   ├── init_db.py               # Database initialization
│   ├── fetch_stocks.py          # Fetch stock list from API
│   ├── day.py                  # Enhanced daily data fetch with external events
│   ├── day_original.py         # Original daily data fetch (backup)
│   ├── day_parallel.py         # Parallel daily data fetch
│   ├── db_reset.py             # Database reset and fetch tool
│   ├── week.py                 # Enhanced weekly data fetch with external events
│   ├── week_original.py        # Original weekly data fetch (backup)
│   ├── week_parallel.py        # Parallel weekly data fetch
│   ├── month.py                # Enhanced monthly data fetch with external events
│   ├── month_original.py       # Original monthly data fetch (backup)
│   ├── month_parallel.py       # Parallel monthly data fetch
│   ├── data_validation.py      # Data validation and integrity check
│   ├── data_repair.py          # Data repair tool
│   ├── schedule_config.py      # OpenClaw cron job configuration
│   └── README.md               # Detailed usage documentation
├── references/
│   └── data_sources.md        # Data source documentation
└── D:\xistock\                # Data directory (external)
    └── stock.db             # SQLite database

Data Sources / 数据来源

English:

  • East Money API: Real-time stock quotes and listing information
  • Sina Finance: Historical data for technical analysis
  • Tencent Finance: Alternative data source for redundancy

中文:

  • 东方财富API: 实时股票行情和上市信息
  • 新浪财经: 技术分析历史数据
  • 腾讯财经: 冗余备用数据源

Requirements / 依赖要求

pip install requests
pip install sqlite3
pip install pandas
pip install akshare  # Chinese stock data library

Notes / 注意事项

English:

  • Database file is stored at D:\xistock\stock.db for data persistence
  • Stock list should be updated regularly (e.g., weekly) to capture new listings and delistings
  • API rate limits apply when fetching data; parallel mode improves speed
  • This system is for research and educational purposes; comply with local regulations for actual trading

中文:

  • 数据库文件存储在 D:\xistock\stock.db 确保数据持久化
  • 股票列表应定期更新(如每周)以捕捉新股上市和退市变化
  • 获取数据受API速率限制,并行模式提升速度
  • 本系统仅用于研究和教育目的;实际交易请遵守当地法规

Todo / 待办事项

  • Add incremental update mode (only fetch stocks not updated today)
  • Add external event control to day.py, week.py, and month.py
  • Create database reset and fetch tool (db_reset.py)
  • Add data validation and integrity checks (data_validation.py)
  • Add data repair tool (data_repair.py)
  • Add OpenClaw cron job configuration (schedule_config.py)
  • Integrate with OpenClaw heartbeat for scheduled automatic updates
  • Add advanced analytics and reporting features

References / 参考资料


Version: 1.0.0
Last Updated: 2026-03-13
Author: jakey Email: [email protected] Wechat: jakeycis

安全使用建议
This package appears to do what it says (fetch A‑share K‑line data into a local SQLite DB), but review these before installing: - It hardcodes Windows paths (D:\xistock\...). If you don't want data on your D: drive or are on a non‑Windows machine, update the scripts to use a configurable path before running. - The code performs network requests to Tencent's finance proxy to fetch data; ensure that outgoing network access is acceptable and complies with the data source's terms of service. - Some scripts (db_reset.py, data_repair.py) can reset timestamps or delete files; back up any existing D:\xistock\stock.db/data before running. - SKILL.md mentions multiple data sources and failover, but most shown fetchers use Tencent — if multi‑source failover is important, inspect the omitted files (and schedule_config.py) to confirm behavior. - Run the scripts in a sandbox or test environment first, and scan the remaining/truncated files (schedule_config.py and others not fully shown) to ensure there are no unexpected behaviors.
功能分析
Type: OpenClaw Skill Name: a-stock-get Version: 1.0.0 The skill bundle is a comprehensive A-share stock data collection tool that fetches historical K-line data from legitimate sources (Tencent Finance API and the AkShare library) and stores it in a local SQLite database. The scripts (e.g., day.py, fetch_stocks.py, init_db.py) follow a consistent logic for data acquisition, validation, and repair, with no evidence of data exfiltration, unauthorized remote execution, or malicious prompt injection. While the scripts use hardcoded Windows file paths (D:\xistock\), this appears to be a configuration preference rather than a malicious indicator.
能力评估
Purpose & Capability
The scripts implement the stated purpose (fetch daily/week/month K-line data, maintain stock list, store into SQLite). Minor mismatch: SKILL.md claims multiple data sources (EastMoney/Sina/Tencent) and automatic failover, but the provided fetch scripts predominantly call Tencent (proxy.finance.qq.com). Also the code uses hardcoded Windows paths (D:\xistock\...), which is a platform-specific requirement that isn't called out in 'requirements' and may be surprising to users on non-Windows systems.
Instruction Scope
Runtime instructions in SKILL.md tell the agent/user to run the included Python scripts (init_db.py, fetch_stocks.py, day.py/week.py/month.py, etc.). The scripts read/write the local SQLite DB and many files under D:\xistock (create backups, delete empty files after prompting, reset timestamp fields). They do not attempt to read unrelated system files or request credentials. Be aware that some scripts prompt for interactive confirmation (e.g., deleting files) and others will modify DB timestamps for all stocks (db_reset.py).
Install Mechanism
No install spec is included (instruction-only skill with code files). That minimizes silent installs; nothing is downloaded from external arbitrary URLs. The Python scripts rely on standard pip packages (requests, pandas, akshare) but pip steps are suggested in SKILL.md rather than automatically executed.
Credentials
The skill declares no required environment variables or credentials, and the code does not access external secrets. It does require network access to Tencent's finance proxy to fetch data. The main proportionality concern is the use of absolute filesystem locations (D:\xistock\stock.db and subdirectories) rather than relative or configurable paths — this grants the skill read/write access to that specific location without explicitly declaring it.
Persistence & Privilege
The skill is not set to always:true and uses normal agent invocation. It persists data only to the local SQLite DB and the D:\xistock directories. It does not modify other skills or system-wide agent settings according to the provided files.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install a-stock-get
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /a-stock-get 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
A-share stock data collector initial release: - Automatically fetches and stores daily, weekly, and monthly historical K-line data for all A-share stocks in a local SQLite database. - Supports automated stock list management, multi-frequency data collection, and incremental updates. - Excludes delisted and pre-IPO stocks; tracks last fetch timestamps for each frequency. - Uses multiple data sources (EastMoney, Sina, Tencent) with automatic failover. - Includes parallel fetching, data validation, data repair tools, and OpenClaw scheduling support.
元数据
Slug a-stock-get
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

A股数据获取 A specialized data collection tool for Chinese A-share market 是什么?

Specialized A-share stock data collector. Automatically fetch and store daily/weekly/monthly historical K-line data for all A-share stocks in SQLite database. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 350 次。

如何安装 A股数据获取 A specialized data collection tool for Chinese A-share market?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install a-stock-get」即可一键安装,无需额外配置。

A股数据获取 A specialized data collection tool for Chinese A-share market 是免费的吗?

是的,A股数据获取 A specialized data collection tool for Chinese A-share market 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

A股数据获取 A specialized data collection tool for Chinese A-share market 支持哪些平台?

A股数据获取 A specialized data collection tool for Chinese A-share market 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 A股数据获取 A specialized data collection tool for Chinese A-share market?

由 小潴(@xiyunnet)开发并维护,当前版本 v1.0.0。

💬 留言讨论