CNEquity

io.github.rootSuncv0.16.0Updated Oct 8, 2026

China A-share data lake for AI agents: prices, fundamentals, flows and events, point-in-time.

VerifiedSTDIODesktop onlyDatabasesFinanceData & Analytics

Overview

AI-generated overview

Lets an assistant query a locally built China A-share data lake of prices, fundamentals, flows and events through read-only MCP tools.

What it does
CNEquity collects multi-source China market data — daily and optional minute bars, financial statements, corporate events, fund flows, sector and macro data, plus futures and options — into a local Parquet data lake. The MCP server exposes six read-only tool groups over that lake: dataset description, symbol resolution, quotes, financials, generic dataset access and SQL. Data is versioned with row-level source, data version and fetch timestamps, and supports point-in-time and adjusted-price query semantics.
When to use it
Worth adding when you want an assistant to answer repeated questions over self-hosted historical A-share data, such as adjusted returns across dividends, point-in-time fundamentals, historical stock universes including delisted names, or valuation and fund-flow research. For a one-off latest quote, calling a data API directly is lighter.
Requirements
Runs locally as a Python package (Python 3.10+ on macOS, Linux or Windows) via uvx or pip install cnequity; no account or token is needed for basic collection. A data lake must first be initialized with cne init, and the MCP server is started with cne mcp --config pointing at an absolute config path. Network access to public data sources is required; some supplementary sources need your own credentials.
Before you install
The MCP server is read-only over the local lake, but the CLI writes data: cne init and cne run daily download and store data, and cne serve can install scheduled daily jobs for the current user. Initializing a full-market lake can take hours and consumes disk. Data comes from third-party public sources and remains subject to their licenses; the repository ships no data lake. The project is at 0.x, so the PyPI release may lag the documentation.

Installation

In SourceWeft

  1. Open CNEquity in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

[CNEquity · 中国市场金融数据湖]

CNEquity · 中国市场金融数据湖

打破数据垄断,构建属于每个人的本地金融数据集

CNEquity 将股票行情、期货合约、财报、公司事件和资金面等多源数据整理为本地 Parquet 数据湖,提供增量采集、失败续跑、质量审计与统一查询。适合反复回测、积累历史数据。提供个人研究者和AI Agent一套完整的金融数据解决方案。

[CI] [PyPI] [Python 3.10+] [Apache-2.0]

English · 完整文档 · 数据集目录 · 更新日志

[cne serve 控制台录屏:湖状态、覆盖热力、日线详情与质量审计]

cne serve 控制台真实录屏。

快速开始

需要 Python 3.10+(macOS / Linux / Windows),不需要账号或 token。

① 一分钟试用。 用真实数据源抓 5 只股票最近 30 个交易日,建在独立目录里,不影响以后的正式湖:

bash
pip install cnequitycne init --profile demo   # 约 1 分钟;结束时打印行情表、查询示例和接给 AI 的命令cne serve --config configs/cnequity.demo.toml   # 在浏览器里打开上面的控制台

② 让 AI 直接查 A 股。 把湖以只读方式接给 Claude、ChatGPT、Codex、Gemini CLI、Cursor、VS Code 等支持 MCP 的客户端(--config 用绝对路径)。以 Claude Code 为例:

bash
claude mcp add cnequity -- cne mcp --config /abs/path/to/configs/cnequity.demo.toml

各家客户端的写法见 MCP 接入指南;ChatGPT 只接公网网址,用 cne mcp --http --token 加隧道接入。然后直接问:「宁德时代最近 30 个交易日的最高收盘价是哪天?」

③ 建正式湖。 沪深京全市场、最近 3 年:

bash
cne init     # 第一次可能需要几个小时;中途断了再运行一次即可续跑,已下载的部分不会重来cne check    # 检查数据是否完整、可用
python
from cnequity.query import load
bars = load("daily_bars", symbols=["600519.SH"])print(bars.tail())

之后每天运行一次 cne run daily 保持更新。想要更长的历史,或了解 init 具体做了什么,见初始化指南。

数据范围

当前开发树注册 55 个数据集:47 个 curated + 8 个 derived,按用途分为 L0–L9。完整字段、主键、历史起点和来源集中在数据集目录与数据源说明。

层次研究用途代表数据集
L0基础参考证券主数据、交易日历、交易状态
L1行情日线、指数、复权因子、可选分钟线与分笔、退市事件
L2公司事件公司行为、公告索引、业绩披露预约
L3基本面财报、估值、股本、股东、一致预期
L4资金面北向、融资融券、龙虎榜、大宗交易、资金流
L5结构行业指数成分、行业与板块成分、行业指数
L6宏观宏观指标、市场宽度
L7舆情与轮动新闻、快讯、情绪、人气、板块行情与资金流
L8风险合规解禁日程、监管事件
L9衍生品期货与期权合约、逐合约行情、连续合约、Greeks、分钟线

分钟线、分笔和期货/期权默认关闭;按需启用后仍须检查来源的历史视野与实际覆盖。

展开注册表的主备来源速查(实际路由与历史限制见数据集目录)
数据集层次登记主源登记备源
instrumentsL0tdx_protocolbaostock
etf_profilesL0exchange—
trading_calendarL0tdx_protocolexchange
trading_statusL0eastmoneyexchange
adj_factorsL1sinabaostock
daily_barsL1tdx_protocoleastmoney
delisting_eventsL1derived—
index_barsL1tdx_protocoleastmoney
minute_barsL1tdx_protocol—
minute_bars_5mL1tdx_protocol—
minute_bars_15mL1derived—
minute_bars_30mL1derived—
minute_bars_60mL1derived—
trade_ticksL1tdx_protocol—
announcement_indexL2cninfo—
corporate_actionsL2eastmoneytdx_protocol
earnings_disclosure_scheduleL2eastmoney—
analyst_consensusL3eastmoney—
financial_statement_itemsL3eastmoney—
share_structureL3eastmoney—
shareholder_countsL3eastmoney—
top_holdersL3eastmoney—
valuation_metricsL3eastmoney—
block_tradesL4eastmoneyexchange
dragon_tigerL4eastmoneyexchange
fund_flowL4eastmoney—
fund_flow_thsL4ths—
institutional_holdingsL4eastmoney—
margin_tradingL4exchange—
northbound_flowsL4eastmoney—
northbound_holdingsL4eastmoney—
index_constituentsL5eastmoney—
industry_indexL5derived—
industry_membersL5eastmoney—
sector_membersL5eastmoney—
macro_indicatorsL6eastmoneypboc
market_breadthL6derived—
economic_calendarL7eastmoney—
flash_news_wireL7eastmoney—
hot_rankL7eastmoney—
news_headlinesL7eastmoney—
sector_barsL7ths—
sector_fund_flowL7eastmoney—
sector_fund_flow_thsL7ths—
sentiment_scoresL7derivedeastmoney
regulatory_eventsL8cninfo—
share_unlock_scheduleL8eastmoney—
commodity_barsL9sinaeastmoney
futures_barsL9futures_exchange—
futures_continuousL9derived—
futures_contractsL9futures_exchange—
futures_minute_barsL9sina—
option_barsL9futures_exchange—
option_contractsL9futures_exchange—
option_greeksL9derived—

登记主备源是数据集元数据;日更 tip、历史回填和显式修复可能走不同路径。请结合来源说明使用。

为什么值得把数据管起来

  • 少写重复的数据工程。 代码、字段、分区和增量窗口由数据层管理;中断后保留成功批次,按失败范围续跑。22 条源探针路由帮助诊断可达性(高成本端点需显式选择)。
  • 把研究口径说清楚。 原始价与复权因子分开存;历史股票池保留退市身份;财报查询区分严格 PIT 与事后重建。
  • 结果有来源,也有版本。 行级 source、data_version、fetched_at 配合不可变数据版本与研究快照,支持复查和重现。
  • 数据留在自己手里。 开放的 Parquet 文件,通过 Python、DuckDB、Polars、控制台和只读 MCP 消费。

幸存者偏差:今天的名单不能代替历史股票池

同一等权买入持有策略、同一时间窗口,仅按今天仍在交易的股票回看过去,会漏掉后来退市的标的。下图用历史样本展示两种股票池得到的结果差异:

[含退市股与只留幸存者的历史等权持有结果对比]

历史样本仅用于说明股票池口径;图中收益和标的数量不代表当前湖覆盖或未来投资表现。退市股按最后一根可用行情计价,因子及退市覆盖限制见股票池画像。

CNEquity 在数据层保留退市身份,并让复权、历史成分和 PIT 口径进入查询契约,避免下游研究在无意中丢掉这些标的。

能用它研究什么

你的问题数据与入口需要确认的口径
跨分红、送转后的历史收益daily_bars + adj_factors · 复权示例adjust="hfq",研究时开启 strict_adj=True
某个调仓日已经知道哪些财报信息financial_statement_items · PIT 示例显式 as_of + pit_mode="strict";新回填不等于当时可见
历史股票池、退市前行情instruments、trading_status、delisting_events · 股票池画像历史 ST、退市和行情覆盖需另行核验
估值、资金流、行业轮动valuation_metrics、资金面与结构数据 · 查询指南分清可回补历史与启用后积累的快照
期货期限结构、期权链与 Greeks逐合约行情和派生数据 · 衍生品指南默认关闭,按交易所、合约生命周期与覆盖证据验收

架构

[CNEquity 从多源采集、编排到本地 Parquet 湖及研究消费的架构图]

数据经适配器与批次编排进入 staging,校验后发布为 curated 或 derived 数据;质量审计、Python/SQL 查询、控制台和 MCP 围绕已发布数据工作。图示用于说明职责边界,具体来源协议与启用状态以数据流说明和数据集目录为准。

初始化之后:每日更新

bash
cne run daily

每天(含周末)用系统调度器运行这一条:交易日跑行情及其他已启用的日更组,然后更新公告、监管事件和资讯;非交易日只更新事件流。cne serve 的操作页也可以为当前用户安装定时日更和收尾补抓,不必复制仓库脚本。验收用 cne check,有缺口或质量 error 时返回非零。

升级版本时:

bash
pip install -U cnequitycne config upgrade

cne config upgrade 把新版本加入的调度 step 补进你的配置,原文件自动备份。

继续阅读:初始化、范围与续跑 → 日常运维。

Python、SQL 和 AI agent 共用一份数据

已建立含复权因子的正式湖后:

python
from cnequity.query import load
bars = load(    "daily_bars",    symbols=["600519.SH"],    start="2024-01-01",    end="2024-12-31",    adjust="hfq",    strict_adj=True,)print(bars.select("trade_date", "close", "adj_close", "adj_is_exact"))
bash
cne query --sql "SELECT symbol, max(trade_date) AS last_date FROM daily_bars GROUP BY symbol LIMIT 10"cne mcp --config /abs/path/to/cnequity.toml

load() 提供复权、PIT 和股票池语义;scan() 提供原始 LazyFrame。MCP 默认只读本地湖,提供描述、代码解析、行情、财报、通用数据集和 SQL 六类工具。客户端配置见 MCP 指南,查询边界见 Python API。

适合与边界

适合持续积累历史、反复查询、检查研究口径和自托管数据的工作。若只需偶尔取一个最新报价,直接调用取数接口通常更轻;已有研究或交易平台也可以把 CNEquity 放在数据层,见选型说明;和 AKShare、Tushare 的区别与配合见对比说明。

  • 当前处于 0.x 迭代阶段。本仓库文档对应当前实现,PyPI 稳定版可能落后;升级前核对 cne --version 和更新日志。
  • 公共来源的网络可达性、历史深度和发布节奏会变化。基础采集无需 token,部分补充来源需要自备凭证;安装不代表获得所有上游权限。
  • fresh 表示新鲜度,不能单独证明历史完整或研究有效。严格 PIT 可能返回空结果,历史股票池可能因证据不足拒绝读取。
  • 项目提供数据基础设施,不含回测引擎、交易信号或下单功能。代码采用 Apache-2.0,数据另受上游许可约束,仓库不附带数据湖。

文档与参与

想做什么从这里开始
安装、跑通首个查询安装 · 快速开始
找数据、确认口径目录 · 字段 · 研究示例
查命令、参数和副作用CLI · 参数默认值 · 联网与写入清单
配调度、处理失败运行手册 · 取数与源保护 · 排障
理解产品方向与反馈问题产品设计 · 升级与反馈

欢迎提交带最小复现的 Issue、文档修正或数据适配 PR。研究引用见 CITATION.cff;安全问题请按安全策略私下报告。

觉得有用?点一个 Star,或把项目分享给同样在维护 A 股数据的人。

Source: README.md at commit c118038

Tools

0
Tool metadata has not been indexed yet.

Version history

1
  1. v0.16.0LatestOct 8, 2026