Skip to main content

CNEquity — 开源的中国市场金融数据基础设施

从 A 股开始,把分散的市场数据变成可复查的本地底座。 一条命令落地、持续日更,供 Python、DuckDB、Polars 和 AI agent 使用。

CLI:cne · 包名:cnequity · Python ≥ 3.10 · 只做数据基础设施(回测和信号留给下游)。

PyPI version

  • 真数上手:cne init --profile demo 几分钟出真实日线(不是 mock);--research 可验证复权口径
  • 日更能挂着跑:水位 / 失败重试 / 质量审计
  • 研究口径一次定好:复权 · universe · PIT;相对拉数库多编排,相对云端宽表可本地续跑

安装与一分钟体验

需要 Python 3.10+,且能访问 TDX 行情主机(大陆出口更稳)。

pip install cnequity
cne init --profile demo

海外或受限网络无法连接 TDX 时,可先运行 cne init --profile sample。它不访问网络,生成的合成行全部标记为 source=mock,仅用于验证安装、Parquet 落盘和查询链路。

写入 data/cnequity-demo/(几只流动性股票 × 约 30 个交易日),并打印样例表。

要验证复权口径,可运行 cne init --profile demo --research --symbols 600519.SH;它会额外读取 Sina 复权因子, 并打印约三年窗口的 raw / hfq 收益对照。

cne query --config configs/cnequity.demo.toml --sql "
  SELECT symbol, trade_date, close, volume, source
  FROM daily_bars
  WHERE symbol = '600519.SH'
  ORDER BY trade_date DESC
  LIMIT 10
"

全量日更(仍不必 clone;在含配置的工作目录执行):

cne config create                              # → configs/cnequity.toml(data.root 写为绝对路径)
# 或显式指定:
# cne config create --data-root /data/cnequity --force
cne config validate --config configs/cnequity.toml
cne init --config configs/cnequity.toml
cne run daily --all-groups --config configs/cnequity.toml   # 之后每个交易日

日更按调度组执行,一天 6 个:core、capital、signals、fundamentals、macro_risk、research。 --all-groups 按配置顺序串行跑完全部组(某组失败不影响后面的组)。 不带 --group / --all-groups 的 cne run daily 只跑 [[job.daily.waves]] 里的核心骨架(行情、日历、 交易状态、公司行为、复权),不含估值、财报、融资融券、龙虎榜、北向、指数成分等 —— 只跑那一条, 湖会停在 15/42 新鲜。想按组错开挂 cron 见运行手册。

cne init --profile demo

有什么数据

数据集名即 load() 的第一个参数。字段见 schema,编排元数据见 catalog。

类别 数据集
基础参考 instruments · trading_calendar · trading_status(停复牌 / ST)
行情 daily_bars(未复权) · index_bars · adj_factors · minute_bars / minute_bars_5m(可选日内)
公司事件 corporate_actions · announcement_index · earnings_disclosure_schedule
基本面 / 估值 financial_statement_items(PIT) · valuation_metrics · analyst_consensus
资金面 fund_flow · margin_trading · northbound_flows / northbound_holdings · dragon_tiger · block_trades · institutional_holdings
结构 / 行业 sector_members · index_constituents · industry_members
宏观 macro_indicators · market_breadth
舆情 / 轮动 sentiment_scores · hot_rank · sector_bars · sector_fund_flow · news_headlines
风险 share_unlock_schedule · regulatory_events

读数据

from cnequity.query import load

bars = load("daily_bars", start="2020-01-01", end="2025-12-31", adjust="hfq")
roe = load("financial_statement_items", items=["roe"], as_of="2024-04-30")

无 extras —— pip install cnequity 即装齐所有数据源。

完整文档

详细 schema、runbook、定位对照与合规说明以 GitHub 为准:

代码 Apache-2.0。落盘行情 / 公告仍受上游条款约束——本包不附带、也不再分发数据湖。

Metadata

Release files for cnequity 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnequity 0.10.0
File Size Uploaded
cnequity-0.10.0.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cnequity 0.10.0
File Interpreter ABI Platform
cnequity-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.6 MB

Release files / cnequity-0.10.0.tar.gz

Download URL cnequity-0.10.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
8a72212a26c98dd3923583ca0d44daa51280818eb459ea1185cccc3127b38e2a
BLAKE2b-256 checksum
How to use checksums
b3d340ac31fa668591a06fb50ed3243c99f900bbb738f1935ee5b3aef86e4f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / cnequity-0.10.0-py3-none-any.whl

Download URL cnequity-0.10.0-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c9c8f21e53c9dfd477eb22c36db35caea9487a729743b353b070690ac144692f
BLAKE2b-256 checksum
How to use checksums
cee00ab1b35a7b2cfab7994935c0114935c25e95f9de8de46a6cf2f950b5a964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.12.0

2 release files

0.11.0

2 release files

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page