CNEquity — China A-Share Data Lake for AI Agents
This is a read-only MCP server for exploring and querying the CNEquity China A-share data lake.
Inspect the lake: list datasets, coverage windows, freshness, history mode, and query contract via
describe_lake.Resolve symbols: turn company names or partial codes into canonical suffixed symbols, including delisted names.
Query price bars: fetch daily or intraday bars with
qfq/hfq/total_returnadjustment, universe filtering, pagination, and optional provenance.Query fundamentals point-in-time: retrieve financial statement items using
as_ofto avoid look-ahead, with vintage andpit_modecontrols.Query other datasets: read fund flow, margin trading, dragon-tiger, block trades, valuations, corporate actions, index constituents, and more.
Run read-only SQL: aggregate, rank, compute percentiles, and join across datasets, including ready-made adjusted-bar views.
Read-only by design: no writes or DDL; responses report totals/truncation and can include per-row source/version metadata.
CNEquity 是开源的中国 A 股本地数据湖:整理沪深京股票行情、公司事件、财务与期货期权数据,面向量化研究、量化交易与回测。86 个数据集经 DuckLake 湖目录原子发布到本地 Parquet,支持按覆盖台账增量续跑,也能通过 MCP 让 AI 直接查 A 股。
English · 完整文档 · 数据集目录 · 更新日志 · 发布记录

cne serve 控制台录屏,使用覆盖 L0–L9 的离线合成样例数据。
为什么用 CNEquity
和常用取数工具的区别(设计取舍见整体设计):
AKShare | Tushare Pro | Baostock | CNEquity | |
账号与 Token | 不需要 | 注册 + Token,按积分开放 | 不需要,匿名登录 | 基础采集不需要;可选接入 Tushare 等付费源回填 |
数据落盘与增量 | 调用方自己做 | 调用方自己做 | 调用方自己做 | DuckLake 湖目录 + 文件即分区 Parquet,覆盖台账驱动增量与续跑 |
退市股与 PIT 财报 | 取决于接口 | 取决于接口 | 部分提供 | 版本化历史股票池保留退市股,财报按披露时点严格 PIT |
行级溯源与版本复现 | 无 | 无 | 无 | 每行带 |
给 AI 用 | 自己封装 | 自己封装 | 自己封装 |
|
Related MCP server: ashareapi
快速开始
需要 Python 3.11+(依赖 DuckDB 2.0+,支持 macOS / Linux / Windows),基础采集不需要账号或 token。小内存或小磁盘机器可先看资源配置建议。
① 一分钟试用。 用真实数据源抓 5 只股票最近 30 个交易日,建在独立目录里,不影响以后的正式湖(离线环境可用 cne init --profile sample 生成合成样例湖):
pip install cnequity
cne 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 为例:
claude mcp add cnequity -- cne mcp --config /abs/path/to/configs/cnequity.demo.toml各家客户端的写法见 MCP 接入指南;ChatGPT 只接公网网址,用 cne mcp --http --token 加隧道接入。然后直接问:「宁德时代最近 30 个交易日的最高收盘价是哪天?」
真实 MCP 工具调用与返回;收盘价为未复权价。
③ 建正式湖。 沪深京全市场、最近 3 年:
cne init # 开始建正式湖,支持中断续跑
cne check # 检查数据是否完整、可用from cnequity.query import load
bars = load("daily_bars", symbols=["600519.SH"])
print(bars.tail())之后每天运行一次 cne run daily 保持更新。想要更长的历史(cne init --profile full),或了解 init 的范围与续跑方式,见快速开始。
能用它研究什么
你的问题 | 数据与入口 |
跨分红、送转后的历史收益 |
|
某个调仓日已经知道哪些财报信息 |
|
历史股票池、退市前行情 |
|
估值、资金流、行业轮动 |
|
期货期限结构、期权链与 Greeks | 逐合约行情和派生数据 · 分钟线与衍生品 |
数据范围
支持 86 个数据集(78 个采集数据集、8 个派生数据集),按用途分为 L0–L9。支持档位、主键、历史起点和来源见数据集目录与字段与单位。
层次 | 研究用途 | 代表数据集 |
L0 | 基础参考 | 证券主数据、交易日历、交易状态、曾用名、可转债与高管资料 |
L1 | 行情 | 日线、指数、可转债行情、涨跌停价、复权因子、可选分钟线与分笔、退市事件 |
L2 | 公司事件 | 公司行为、公告索引、业绩预告与披露预约、股东增减持、股份回购、可转债转股与强赎 |
L3 | 基本面 | 财报、主营构成、估值、股本、股东人数与十大股东、高管薪酬、一致预期与券商预测 |
L4 | 资金面 | 北向资金与十大成交、融资融券、龙虎榜、游资名录与明细、涨停与连板天梯、筹码分布、大宗交易、资金流 |
L5 | 结构行业 | 指数成分、行业与板块成分、行业指数 |
L6 | 宏观 | 宏观指标、市场宽度 |
L7 | 舆情与轮动 | 新闻、快讯、互动易问答、情绪、人气与最强板块、板块行情与资金流、财经日历 |
L8 | 风险合规 | 股权质押、解禁日程、监管事件 |
L9 | 衍生品 | 期货与期权合约、逐合约行情、商品日线、期货会员持仓、连续合约、Greeks、分钟线 |
分钟线、分笔、期货/期权,以及资金流、新闻、人气榜等尽力而为与可选数据集默认关闭,需要时可在配置中打开。
架构
代码分为市场无关的湖引擎 equitylake_core(DuckLake 湖目录 lake/catalog.sqlite、文件即分区 Parquet、无长锁分区检出合并、覆盖台账 _attempts 与缺口规划器)与 A 股市场层 cnequity(L0–L9 契约、多源适配器、三层质量门禁、查询语义与 CLI)。外部工具需要直接读 Parquet 文件时使用 cne storage export 导出。详见整体设计。
幸存者偏差
今天的名单不能代替历史股票池。 回测时在 load() 中通过版本化股票池 profile(如 cn_a_sh_sz_research_v1)按研究日期筛选,避免丢掉当时已上市、后来退市的股票。
日常更新与升级
cne schedule install # 为当前用户安装每日定时任务(macOS / Linux / Windows)
cne run daily # 或者自己每天运行一次
cne check # 验收;有缺口或质量 error 时返回非零升级:pip install -U cnequity,然后运行 cne upgrade(先预览,确认后加 cne upgrade --apply 一步完成湖目录迁移;完整展开的旧配置可运行 cne config upgrade)。0.25.0 起湖目录成为唯一的存储方式,0.25.x 是最后一个能升级 0.24.0 及更早湖的版本系列。升级前请先备份数据目录并阅读升级到 0.25.0。调度、操作页、磁盘占用(cne storage usage)和失败后续见日常更新。
适合与边界
适合持续积累历史、反复查询和自托管。
项目处于 0.x,不含回测引擎或下单。代码采用 Apache-2.0,数据另受上游许可约束,仓库不附带数据湖。
文档与参与
想做什么 | 从这里开始 |
安装、跑通首个查询或升级旧湖 | 安装与升级 · 升级到 0.25.0 · 快速开始 |
找数据、确认口径 | |
用 Python、SQL、MCP 查询 | Python API · MCP 接入 · 查询指南 |
查命令、配置和副作用 | |
配调度、处理失败 | |
理解整体设计与反馈问题 |
欢迎提交带最小复现的 Issue、文档修正或数据适配 PR。研究引用见 CITATION.cff;安全问题请按安全策略私下报告。
觉得有用?点一个 Star,或把项目分享给同样在维护 A 股数据的人。
Available Tools
6 toolsdescribe_lakeARead-only
START HERE. Returns what this lake actually holds — every dataset with its coverage window, history mode and freshness — plus the query contract that makes an answer correct (adjustment, point-in-time, which series have no real history). Cheap, reads no data. Call it before answering anything factual about A-share data, and use its coverage_start/coverage_end to tell 'this lake has no such data' apart from 'this did not happen'. It also reports live_mode — when that is on, some answers come from the vendor rather than the lake and say so. Then pick a tool: resolve_symbol for names, query_bars for prices, query_fundamentals for financials, query_dataset for everything else, run_sql for aggregation.
Inputs: include_empty.
query_barsARead-only
Daily or intraday price bars. PRICES ARE STORED UNADJUSTED: pass adjust='hfq' for any comparison across time (returns, charts, drawdowns) or a split reads as a crash. Use adjust='qfq' when the levels must match what a quote screen shows today. Pass universe='all_a' for cross-sectional work to drop names that were not tradable that day. datasets: daily_bars, index_bars, minute_bars (1m), minute_bars_5m (5m), and minute_bars_15m / _30m / _60m when the user has derived them (each bar's resampled_from says whether 1m or 5m built it). Every response carries origin: 'lake' is stored and validated; 'live' was fetched just now and cannot be adjusted or universe-filtered — read its warning before using the numbers for anything but a current quote. Not for financial statements (query_fundamentals), other datasets such as fund flow (query_dataset), or ranking and aggregating across many symbols (run_sql).
Inputs: end, limit, start, adjust, +5 more.
query_datasetARead-only
Read any other dataset by date window and symbol — fund_flow, margin_trading, dragon_tiger, block_trades, northbound_holdings, share_unlock_schedule, corporate_actions, valuation_metrics, index_constituents and the rest. Call describe_lake for the full list and each one's coverage. Bars go through query_bars and financial statements through query_fundamentals. Results are paged with limit/offset and the response reports the true total and a truncated flag; for cross-sectional ranking use run_sql instead of paging.
Inputs: dataset (required), end, limit, start, +3 more.
query_fundamentalsARead-only
Financial statement items, point-in-time. as_of is REQUIRED and is what prevents look-ahead: only figures publicly announced on or before that date come back, and a restated figure returns the vintage that was current then. For a present-day view pass today's date; for a historical study pass the date being studied, never today. Results are paged with limit/offset. For prices use query_bars; for valuation ratios read valuation_metrics through query_dataset. Set pit_mode='strict' only to audit what the lake itself held on that date.
Inputs: as_of (required), items, limit, offset, +3 more.
resolve_symbolARead-only
Look up a symbol by company name or partial code — '茅台', 'maotai', '600519' all resolve to 600519.SH. Do this before any query when the user named a company rather than a code: a guessed suffix returns an empty result rather than an error. Delisted names are included and flagged with delist_date. Returns the canonical symbol, name and delist_date; several rows mean the fragment is ambiguous, so pick by name before querying.
Inputs: query (required), limit.
run_sqlARead-only
One read-only DuckDB SELECT over every dataset, each exposed as a view under its own name. Use this for ranking, aggregation, percentiles and joins across datasets — computing them here is both correct and far cheaper than paging thousands of rows back and adding them up. daily_bars_adj is a ready-made view carrying hfq_open/high/low/close and open-lake qfq_* beside the raw columns; for a bounded historical qfq window use daily_bars_qfq(start_date, end_date) so the anchor matches that window. Prefer these over joining adj_factors yourself. Single SELECT only: no writes, DDL or multiple statements. For one symbol's bars use query_bars, and for plain dataset reads query_dataset.
Inputs: sql (required), limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool owns a distinct job: describe_lake for metadata/contract, resolve_symbol for identifier lookup, query_bars for prices, query_fundamentals for statements, query_dataset for all other datasets, and run_sql for aggregation. The descriptions actively cross-route ('Bars go through query_bars... for cross-sectional ranking use run_sql'), neutralizing the one potential overlap between query_dataset and run_sql.
All names follow a consistent snake_case verb_noun pattern (describe_lake, resolve_symbol, query_bars, query_fundamentals, query_dataset, run_sql). Verbs vary appropriately by action rather than arbitrarily, so the convention is predictable and readable.
Six tools is well-scoped for a data lake spanning dozens of datasets: rather than one tool per dataset, the design consolidates with query_dataset and run_sql, so every tool earns its place. Neither bloated nor thin.
The read lifecycle is essentially complete — discover contents, resolve identifiers, query prices, financials, and arbitrary datasets, then aggregate in SQL with adjustment views provided. Minor gap: no explicit per-dataset column/schema discovery tool, though DuckDB views via run_sql largely fill it.
Maintenance
Related MCP Connectors
China A-share market data for research, backtesting and AI agents via MCP.
China A-share data for AI agents: 57 read-only tools plus 6 tools for your own watchlist.
Aligned market data for AI agents: crypto, stocks, FX and macro on one clock. Local or hosted.
China A-share market data over MCP: 22 tools for quotes, K-line, financials, money flow, top-trader boards, sectors, macro, convertible bonds and factor screening. Five tools need no API key, so you can connect and try it immediately.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query Chinese A-share market data — real-time quotes, K-lines, order books, financials, fund flows, dragon-tiger lists, sectors, convertible bonds, macro data, and factor screening — through 24 tools, five of which require no API key. It can be used via a hosted endpoint with no installation or self-hosted locally over stdio.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to pull live China A-share market data through 24 tools spanning real-time quotes, K-lines, five-level order books, financials, money flow, dragon-tiger lists, sector and valuation data, convertible bonds, ETFs, IPOs, macro indicators, and factor-based stock screening. Five of the tools work with no API key, while the rest require a paid key.250 npm1MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI agents and regular backends to fetch and analyze financial market data across A-shares, US equities, ETFs, indices, and crypto, including quotes, K-lines, technical indicators, fundamentals, money flow, filings, and news search. Exposes these capabilities both as MCP tools for clients like Claude Desktop and Cursor and as an HTTP API with CSV/JSON export suited to code-executing agent workflows.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents and regular backends or scripts to access standardized financial market data and analysis across A-shares, US equities, ETFs, indices, and crypto, including technical indicators, fundamentals, money flow, news, filings, and CSV/JSON exports.-