Skip to main content

AShareHub Python SDK

Official Python SDK for Chinese A-Share Market Data

PyPI version Python versions License: MIT

Website • Documentation • API Reference • MCP & Skill • Get API Key


Overview

AShareHub provides institutional-grade Chinese A-Share market data through a simple, modern Python SDK. Access real-time and historical data for all listed Chinese A-shares.

Key Features:

  • Returns pd.DataFrame — same convention as Tushare
  • 47 data endpoints covering stocks, ETFs, financials, real-time, news, and reference data
  • 10+ years of historical data
  • Secure API key authentication
  • Fast and reliable

Installation

pip install asharehub

Requirements: Python 3.10+, pandas


Quick Start

from asharehub import AShareHub

client = AShareHub(api_key="ash_your_key_here")

# Get daily market data — returns pd.DataFrame
df = client.market_daily(symbol="000001.SZ", start_date="20240101", end_date="20241231")
print(df[["trade_date", "open", "high", "low", "close", "vol"]])

client.close()

API Methods

All methods return pd.DataFrame. Empty results return an empty DataFrame (df.empty == True).

Market Data

df = client.market_daily(symbol="000001.SZ", start_date="20240101")
df = client.fundamentals(symbol="000001.SZ", start_date="20240101")
df = client.margin(symbol="000001.SZ")
df = client.block_trade(symbol="000001.SZ")
df = client.top_list()
df = client.shareholders(symbol="000001.SZ")
df = client.holder_trade(symbol="000001.SZ")
df = client.concepts()
df = client.concept_members(symbol="BK0425.DC")
df = client.adj_factor(symbol="000001.SZ")
df = client.technical_factors(symbol="000001.SZ")
df = client.limit_list(limit_type="U")

Capital Flows

df = client.moneyflow_hsgt(start_date="20240101")
df = client.moneyflow(symbol="000001.SZ")
df = client.northbound_holdings(symbol="000001.SZ")

Financials

df = client.financial_indicators(symbol="000001.SZ")
df = client.income(symbol="000001.SZ")
df = client.balance_sheet(symbol="000001.SZ")
df = client.cash_flow(symbol="000001.SZ")
df = client.forecast(symbol="000001.SZ")
df = client.express(symbol="000001.SZ")
df = client.dividend(symbol="000001.SZ")

Indices

df = client.index_daily(symbol="000300.SH", start_date="20240101")
df = client.index_weight(symbol="399300.SZ")

ETFs

df = client.etf_basic(list_status="L")
df = client.etf_indices()
df = client.etf_daily(symbol="510300.SH", start_date="20260101")
df = client.etf_adj_factor(symbol="510300.SH", start_date="20260101")
df = client.etf_share_size(symbol="510300.SH", start_date="20260101")
df = client.etf_nav(symbol="510300.SH", start_date="20260101")
df = client.etf_portfolio(symbol="510300.SH", period="20260331")

Other

df = client.chip_distribution(symbol="000001.SZ")
df = client.fx_daily(symbol="USDCNH.FXCM")

Reference Data

df = client.stock_list()
df = client.industry_list()
df = client.trade_calendar(exchange="SSE", start_date="20240101")

Common Parameters

All data methods accept:

Parameter Type Description
symbol str Suffixed stock/index/ETF code, e.g. 000001.SZ
start_date str Start date, YYYYMMDD
end_date str End date, YYYYMMDD

Common Index Codes

Code Name
000001.SH SSE Composite (上证综指)
000300.SH CSI 300 (沪深300)
399001.SZ SZSE Component (深证成指)
399006.SZ ChiNext (创业板指)
000016.SH SSE 50 (上证50)

Authentication

Get your free API key:

  1. Visit asharehub.com/en/console/register
  2. Create an account
  3. Generate your API key in the dashboard

Free tier includes 100 API calls per day.


Error Handling

from asharehub import AShareHub
import httpx

client = AShareHub(api_key="your_key")

try:
    df = client.market_daily(symbol="000001.SZ")
except httpx.HTTPStatusError as e:
    if e.response.status_code == 401:
        print("Invalid API key")
    elif e.response.status_code == 429:
        print("Rate limit exceeded")
    else:
        print(f"HTTP error: {e}")

Advanced Usage

Context Manager

with AShareHub(api_key="your_key") as client:
    df = client.market_daily(symbol="000001.SZ")
    # Client automatically closes when exiting context

Custom Base URL

client = AShareHub(
    api_key="your_key",
    base_url="https://custom.api.url",
    timeout=60.0
)

Rate Limits

Plan Price Daily Limit
Free $0 100 requests
Pro $49/month 10,000 requests
Business $99/month 50,000 requests

Support


License

MIT License - see the LICENSE file for details.


Built for the global investment community

asharehub.com

Metadata

Release files for asharehub 0.8.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 asharehub 0.8.0
File Size Uploaded
asharehub-0.8.0.tar.gz 15.0 kB Details

Built distribution (wheel)

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

Total release size: 27.4 kB

Release files / asharehub-0.8.0.tar.gz

Download URL asharehub-0.8.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c9472c495128b118d5952e8a7f4bab82af587a7a5d5a4edd7ee52752bd66f6d6
BLAKE2b-256 checksum
How to use checksums
987294b33f7f04f197b65be77837a3b208bda068534b191c06ebf21311c0ce25
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 Aug 8, 2026.

Transparency log

Release files / asharehub-0.8.0-py3-none-any.whl

Download URL asharehub-0.8.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1081f2217337356680e48d15ba2f77d689e175bc7e3bf90e3f04c3a7aa139f5
BLAKE2b-256 checksum
How to use checksums
3cb709a79eec8cade9d317a7d0b2ef78b489c860e63aff91e8e187ed0ef2f95a
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 Aug 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.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