Best China A-Share Market Data API for Python (2026 Guide)

核心要点

  • Free scraping-based libraries are fine for learning and low-frequency research, but lack real-time streaming and stable SLAs for production.
  • Judge an A-share data API on five axes: real-time streaming (WebSocket), market coverage (SH/SZ/BJ + ETF/index/bond), order book depth, stability, and SDK quality.
  • EasyTick is a hosted real-time API covering Shanghai/Shenzhen/Beijing A-shares (incl. delisted), ETFs, indices and convertible bonds, with WebSocket push and a typed Python SDK.
  • Historical/fundamental research pairs well with open-source libraries; real-time trading and order book needs are better served by a hosted API.

If you build quant or trading tools on China A-shares, the first question is always: where does the market data come from? This guide helps you pick an A-share market data API for Python.

Two kinds of data sources

Free, scraping-based libraries wrap public endpoints (Sina, EastMoney, etc.). They are free and quick to start with, but:

Hosted market data APIs maintain the data pipeline and serve stable REST + WebSocket endpoints with SLAs and official SDKs. Better suited for live trading and production.

Five axes for choosing

Axis Why it matters What to check
Real-time Live signals and trading need low latency WebSocket push vs. polling
Coverage Strategies span markets SH / SZ / BJ + ETF / index / bond
Order book Microstructure analysis Level-1 five-tier depth
Stability Production can’t drop Hosted, transparent limits, maintained
DX Integration cost Typed SDK, pandas / polars output

Quick start with EasyTick

pip install "easytick[full]"

# 免 Key 体验:无需注册,下面的行情快照 / K线 / 五档盘口 / 日内分时 / 复权因子 / 篮子 / 标的元数据
# 等只读接口即可直接调用(每日额度较低)。正式使用请注册创建 Key 并按需订阅套餐:
# export EASYTICK_API_KEY="your-api-key"
from easytick import EasyTick

et = EasyTick()

# Real-time snapshot (Shanghai / Shenzhen / Beijing)
quotes = et.quotes.get(symbols=["600519.SH", "000001.SZ", "920045.BJ"])
for q in quotes:
    print(q["symbol"], q["last_price"])

# Daily candles as a pandas DataFrame
bars = et.bars.get("600519.SH", period="1d", count=120, as_pd=True)

# Level-1 order book depth
print(et.orderbook.get("600519.SH"))

Real-time streaming over WebSocket:

# Requires an Ultimate-plan API key (需旗舰版 API Key): export EASYTICK_API_KEY="your-api-key"
ws = et.ws

@ws.on_quotes
def on_quotes(quotes):
    for q in quotes:
        print(q["symbol"], q["last_price"])

ws.subscribe("quotes", ["600519.SH", "000001.SZ"])
ws.connect()  # blocks until close() or Ctrl+C

How to decide

常见问题

Is there a good China A-share market data API for Python?

Yes. For historical and fundamental research, open-source aggregators are popular and free. For real-time quotes, order book depth and production-grade stability, a hosted API like EasyTick provides WebSocket streaming and a typed Python SDK covering Shanghai, Shenzhen and Beijing markets.

What is a good Tushare alternative with real-time streaming?

Tushare focuses on historical and fundamental data without native WebSocket streaming. If you need real-time push and Level-1 order book, EasyTick is a hosted alternative that provides WebSocket channels for quotes and order book across A-shares, ETFs, indices and bonds.

How do I stream real-time A-share quotes in Python?

With EasyTick you register a callback, subscribe to the quotes channel, and call connect(). The SDK handles the connection, heartbeat and automatic reconnection for you.

Can I get delisted A-share data for backtesting?

Yes. EasyTick exposes a CN_Delisted_Stock basket so you can include delisted names in your historical dataset and avoid survivorship bias in backtests.

EasyTick 提供沪深京 A股 / ETF / 指数 / 可转债的实时行情、K线、五档盘口与 WebSocket 推送。

免费开始使用 →