by rootSunc
中国股票数据基础设施。42+A股数据集,日更、自托管、MCP 原生,零注册、零 API Token
# Add to your Claude Code skills
git clone https://github.com/rootSunc/CNEquityGuides for using ai agents skills like CNEquity.
Last scanned: 8/16/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-08-16T04:34:23.221Z",
"npmAuditRan": true,
"pipAuditRan": true,
"promptInjectionRan": true
}上图是用于 README 的演示图,不代表当前生产数据状态。真实控制台只读,不会修改数据湖。
CNEquity 把分散在多个来源的行情、基本面、事件、资金、行业与宏观数据,沉淀为开放格式的本地数据层。当前从 A 股出发,但产品边界不止于一次取数或单一市场:同一套采集、质量、溯源和研究契约,可以继续承载更多中国市场数据。
核心边界:适配器负责把多源数据取回来;编排层负责 DAG、批次和重试;数据先进入 staging,再压实为 curated 并计算 derived;质量层持续审计;查询和服务层只读消费。展开见架构说明。
CNEquity 不是又一个”临时请求一次行情”的接口。它更适合这些场景:
如果只想查一只股票的最新价格,直接取数通常更轻;如果要做可复查的历史研究,这个项目才真正有价值。
第一次使用,按这条路径即可:
cne demo → cne init → cne run daily → load() / cne serve → cne mcp(可选)
需要 Python 3.10+,无需 token、积分或账号:
pip install cnequity
cne demo
cne demo 默认拉取 5 只股票最近约 30 个交易日的真实数据,写入独立目录
data/cnequity-demo/,不会覆盖正式数据湖。需要能访问 TDX 行情主机;若连接失败,先检查:
cne sources --only tdx_protocol
然后在 Python 中读取:
from cnequity.query import load
bars = load("daily_bars", data_root="data/cnequity-demo")
print(bars.tail())
想直接比较原始价格与后复权口径:
cne demo --research --symbols 600519.SH
pip install cnequity
cne config init # 生成 configs/cnequity.toml
cne init # 全市场标的,默认回溯最近 3 年
cne run daily # 之后每个交易日执行这一条
默认策略是“浅而不窄”:历史先取最近 3 年,但全市场标的一个不缺。这样不会因为只保留今天仍上市的股票,提前把幸存者偏差写进数据湖。每个数据集的真实起点会记录在 coverage_start。
需要更长历史时可以一次拉满,也可以以后补深:
cne init --profile full
# 或对单个数据集补历史
cne backfill daily_bars --start 2016-01-01 --end <coverage_start>
默认初始化通常是小时级、GB 级,实际取决于网络、数据源状态和机器配置。详细安装说明见快速开始和安装指南。
同一个等权买入持有、同样的起止日期,唯一差别是后来退市的股票是否仍在历史股票池中。用“今天还在的股票”回看历史,2016–2021 五年收益会从 5.9% 变成 12.0%,看起来几乎翻倍。
这类错误很难从结果里发现:那些股票不是收益为零,而是根本没有进入计算。CNEquity 因此把退市股、复权因子、历史成分与 PIT 当作基础能力,而不是附加字段。
复现实验:
python scripts/survivorship_gap.py --lang zh --svg docs/assets/survivorship-gap.zh.svg
| 研究问题 | 推荐入口 |
|---|---|
| 茅台过去五年复权后涨了多少 | load("daily_bars", symbols=[...], adjust="hfq") |
| 茅台 PE 在自身五年历史中的分位数 | valuation_metrics + 窗口分位 |
| 2018 年财报因子的 IC,且不使用未来数据 | load("financial_statement_items", as_of="2018-04-30") |
| 退市股退市前 60 天的价格形态 | delisting_events + daily_bars |
| 三年前的沪深 300 成分或申万行业 | index_constituents · industry_members |
| 今天的龙虎榜、未来解禁和板块资金流 | dragon_tiger · share_unlock_schedule · sector_fund_flow |
常用查询:
from cnequity.query import load
bars = load(
"daily_bars",
start="2020-01-01",
end="2025-12-31",
symbols=["600519.SH"],
adjust="hfq",
)
roe = load(
"financial_statement_items",
items=["roe"],
as_of="2024-04-30",
)
当前注册表包含 42 个数据集:39 个 curated + 3 个 derived。按研究用途分为 L0–L8 九类;完整字段、主键、历史模式和源端限制见数据集目录。
| 层次 | 研究用途 | 代表数据集 |
|---|---|---|
| L0 | 基础参考 | 证券主数据、交易日历、交易状态 |
| L1 | 行情 | 日线、指数、复权因子、分钟线、分笔、退市事件 |
| L2 | 公司事件 | 公司行为、公告索引、预约披露 |
| L3 | 基本面 | 财报、估值、股本、股东、一致预期 |
| L4 | 资金面 | 北向、融资融券、龙虎榜、大宗交易、资金流 |
| L5 | 结构行业 | 指数成分、行业与板块成分 |
| L6 | 宏观 | 宏观指标、市场宽度 |
| L7 | 舆情与轮动 | 新闻、情绪、人气、板块行情与资金流 |
| L8 | 风险合规 | 解禁日程、监管事件 |
所有 curated 行都包含 source、data_version 和 fetched_at,可以追到来源与采集批次。分钟线、5 分钟线和分笔默认关闭,按需启用;部分只能获取当日快照的数据集不会伪造成历史序列。
| 数据集 | 说明 | 主源 | 备源 | 历史 | 日更组 |
|---|---|---|---|---|---|
| L0 · 基础参考 | |||||
instruments |
证券主数据 | tdx_protocol | baostock | 可回补 | core |
trading_calendar |
交易日历 | tdx_protocol | exchange | 可回补 | core |
trading_status |
交易状态(停复牌/ST) | tdx_protocol | eastmoney | 可回补 | core |
| L1 · 行情 | |||||
adj_factors |
复权因子 | sina | — | 可回补 | — |
commodity_bars ○ |
商品期货主连 | sina | eastmoney | 可回补 | macro_risk |
daily_bars |
日线 | tdx_protocol | eastmoney | 可回补 | core |
delisting_events |
退市事件 | derived | — | 可回补 | — |
index_bars |
指数日线 | tdx_protocol | eastmoney | 可回补 | core |
minute_bars ○ |
1 分钟线 | tdx_protocol | — | 可回补 | intraday |
minute_bars_5m ○ |
5 分钟线 | tdx_protocol | — | 可回补 | intraday |
trade_ticks ○ |
分笔快照 | tdx_protocol | — | 可回补 | ticks |
| L2 · 公司事件 | |||||
announcement_index |
公告索引 | cninfo | — | 可回补 | capital |
corporate_actions |
公司行为 | tdx_protocol | eastmoney | 可回补 | core |
earnings_disclosure_schedule |
业绩披露预约 | eastmoney | — | 可回补 | fundamentals |
| L3 · 基本面 | |||||
analyst_consensus |
分析师一致预期 | eastmoney | — | 仅当日 | research |
financial_statement_items |
财务报表科目 | eastmoney | — | 可回补 | fundamentals |
share_structure |
股本结构 | eastmoney | — | 可回补 | fundamentals |
shareholder_counts |
股东户数 | eastmoney | — | 可回补 | fundamentals |
top_holders |
前十大股东 / 流通股东 | eastmoney | — | 可回补 | 按需回填 |
valuation_metrics |
估值指标 | eastmoney | — | 回填 baostock |
capital |
| L4 · 资金面 | |||||
block_trades |
大宗交易 | eastmoney | — | 可回补 | signals |
dragon_tiger |
龙虎榜 | eastmoney | — | 可回补 | signals |
fund_flow |
个股资金流 | eastmoney | — | 仅当日 | capital |
institutional_holdings |
机构持股 | eastmoney | — | 可回补 | research |
margin_trading |
融资融券 | eastmoney | — | 可回补 | capital |
northbound_flows |
北向资金流向 | eastmoney | — | 可回补 | capital |
northbound_holdings |
北向持股 | eastmoney | — | 可回补 | capital |
| L5 · 结构行业 | |||||
index_constituents |
指数成分 | eastmoney | — | 回填 cni |
fundamentals |
industry_index |
行业指数 | derived | — | 可回补 | — |
industry_members |
行业分类成分 | eastmoney | — | 回填 sw |
fundamentals |
sector_members |
板块成分 | eastmoney | — | 仅当日 | capital |
| L6 · 宏观 | |||||
macro_indicators |
宏观指标 | eastmoney | pboc | 可回补 | macro_risk |
market_breadth |
市场宽度 | derived | — | 可回补 | macro_risk |
| L7 · 舆情 / 轮动 | |||||
economic_calendar ○ |
经济日历 | eastmoney | — | 仅当日 | — |
flash_news_wire |
7×24 快讯 | eastmoney | — | 仅当日 | research |
hot_rank |
人气榜 | eastmoney | — | 仅当日 | research |
news_headlines |
新闻标题 | eastmoney | — | 仅当日 | research |
sector_bars |
板块行情 | ths | — | 回填 ths |
research |
sector_fund_flow |
板块资金流 | eastmoney | — | 仅当日 | research |
sentiment_scores |
情绪评分 | derived | eastmoney | 可回补 | research |
| L8 · 风险合规 | |||||
regulatory_events |
监管事件 | cninfo | — | 可回补 | macro_risk |
share_unlock_schedule |
解禁日程 | eastmoney | — | 可回补 | macro_risk |
○ 表示可选数据集,空表不算异常。逐项说明见数据集目录,源端限制见数据源说明。
cne run daily # 执行当天全部日更分组
cne status # 查看 FRESH / STALE / EMPTY
cne serve # 打开 http://127.0.0.1:8787
cne sources # 检查上游数据源健康度
cne retry --run-id <run_id> # 只重试失败批次
单个 step 失败时,系统会记录 failed batch,其他步骤继续落盘;重试不会把整条任务重新跑一遍。浏览器控制台就是 README 首图中的界面,可查看覆盖、新鲜度、容量、跑批和质量结果。
挂入 crontab 即可自动日更:
# 交易日收盘后执行;非交易日会自动跳过
30 16 * * 1-5 cd /path/to/lake && cne run daily >> logs/daily.log 2>&1
cne mcp 以只读方式把本地湖提供给模型;采集、重试和清理仍由 CLI 完成。
cne mcp --config "$(pwd)/configs/cnequity.toml"
把上面的命令作为 MCP server 注册到任意兼容客户端即可。大多数客户端 使用等价的配置(客户端名称和界面可能不同):
{
"mcpServers": {
"cnequity": {
"command": "cne",
"args": ["mcp", "--config", "/abs/path/to/cnequity.toml"]
}
}
}
因此 Codex、Claude、Cline、Cursor、Windsurf、Gemini CLI 以及其它支持
MCP stdio 的 agent 都可以复用同一条 command / args 配置;CNEquity
不依赖任何特定模型或厂商 SDK。
--config 必须使用绝对路径。接好后可以直接问:
还没有正式湖时,可以先运行 cne demo,再使用生成的 demo 配置。完整说明见MCP 参考。
AkShare 和取数工具解决”怎样调用数据源”,Tushare 提供云端数据服务,Qlib / vn.py 更偏研究或交易平台。CNEquity 做的是中间的数据基础设施:把多源数据落成可日更、可复查、可溯源的本地 Parquet 湖。
| 你在意的能力 | CNEquity | 常规取数工具 | 云端数据服务 | 研究 / 交易平台 |
|---|---|---|---|---|
| 本地可续跑的数据底座 | 内置 | 通常自建 | 通常不提供 | 依平台而定 |
| 历史结果能否复查 | 行级溯源 | 缺少统一契约 | 依平台字段 | 依模块而定 |
| 复权 / universe / PIT | 统一在 load() |
自己拼接 | 自己拼接 | 使用平台口径 |
| 单一数据源故障 | 按批失败,可单独重试 | 调用方处理 | 平台处理 | 依模块而定 |
更完整的逐项比较见项目对比。
默认配置拉取全市场最近 3 年,通常约 1 小
CNEquity is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by rootSunc. 中国股票数据基础设施。42+A股数据集,日更、自托管、MCP 原生,零注册、零 API Token. It has 127 GitHub stars.
Yes. CNEquity passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/rootSunc/CNEquity" and add it to your Claude Code skills directory (see the Installation section above).
CNEquity is primarily written in Python. It is open-source under rootSunc on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh CNEquity against similar tools.
No comments yet. Be the first to share your thoughts!