A technical guide for integrating the AkShare Python library to fetch Chinese market data.

Install

mkdir -p .claude/skills/akshare-mastery && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/9623" && unzip -o skill.zip -d .claude/skills/akshare-mastery && rm skill.zip

Installs to .claude/skills/akshare-mastery

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Expert guide for using AkShare to fetch Chinese financial data, covering installation, proxy configuration, resilience patterns, and key interfaces.
148 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Fetch Chinese financial data
  • Configure HTTP proxies
  • Implement resilience patterns
  • Access A-share interfaces

How it works

It provides a wrapper around AkShare interfaces with proxy management and retry logic to handle web scraping instability.

Inputs & outputs

You give it
Stock symbol or market request
You get back
Financial data DataFrame

When to use AkShare Mastery

  • Fetching real-time stock data
  • Configuring HTTP proxies for data scraping
  • Handling AkShare network errors

About this skill

AkShare Mastery Skill

AkShare is an open-source financial data interface library for Python, built for human beings! It fetches data from various sources (Eastmoney, Sina, Xueqiu, etc.) primarily via web scraping.

1. Core Philosophy

  • Data Source Aggregator: AkShare isn't a data provider itself; it's a collected interface for scraping other providers.
  • Dependency: If the upstream source (e.g., Eastmoney) changes its API or blocks IPs, AkShare breaks.
  • No Native Proxy Config: It uses standard Python requests. Proxies must be set via standard environment variables.

2. Installation & Mirror

For faster installation in China, use Aliyun mirror:

pip install akshare --upgrade -i https://mirrors.aliyun.com/pypi/simple/

3. Network & Proxy Configuration (Critical)

Since AkShare scrapes websites, it is vulnerable to IP blocking (403 Forbidden / Connection Reset). To use a proxy:

Method A: Environment Variables (Recommended)

Set these before running your script.

export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"
python main.py

Method B: Python Context (Targeted)

import os
import akshare as ak

# Apply proxy globally for the process just before calling AkShare
os.environ["HTTP_PROXY"] = "http://127.0.0.1:7890"
os.environ["HTTPS_PROXY"] = "http://127.0.0.1:7890"

df = ak.stock_zh_a_spot_em()

4. Key Interfaces (A-Share)

Real-time Quotes

  • Spot Data (All Stocks): ak.stock_zh_a_spot_em()
    • Source: Eastmoney
    • Columns: 代码, 名称, 最新价, 涨跌幅, ...
    • Note: High failure rate if IP is dirty.

Historical Data

  • Daily K-line: ak.stock_zh_a_hist(symbol="000001", period="daily", start_date="20230101", adjust="qfq")
    • Source: Eastmoney
    • Symbols: "000001" (no prefix usually).

Market Breadth / Northbound

  • Northbound Funds: ak.stock_hsgt_fund_flow_summary_em()

5. Resilience Pattern (The "Antigravity" Way)

Never call AkShare directly in production without these wrappers:

  1. Timeout Protection: Blocking calls will hang indefinitely if the server holds the connection. Use asyncio.wait_for or func_timeout.
  2. Retries: Use tenacity library.
  3. Validation: Always check if df.empty.
from tenacity import retry, stop_after_attempt
import akshare as ak

@retry(stop=stop_after_attempt(3))
def safe_fetch_spot():
    df = ak.stock_zh_a_spot_em()
    if df is None or df.empty:
        raise ValueError("Empty response")
    return df

6. Troubleshooting

  • Connection Reset / Timeout: 99% chance your IP is blocked by Eastmoney. Switch IP or wait 2-24 hours.
  • AttributeError: AkShare updates frequently. Run pip install akshare --upgrade.
  • "Zero Data": Check if today is a trading day.

When not to use it

  • When not using Python
  • When the upstream data source is blocked

Prerequisites

pipakshare

Limitations

  • Vulnerable to IP blocking by data sources

How it compares

It adds critical resilience and proxy configuration to standard AkShare usage.

Compared to similar skills

AkShare Mastery side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
AkShare Mastery (this skill)06moReviewIntermediate
crawl4ai218moReviewIntermediate
omero-integration17moReviewAdvanced
kegg-database17moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

crawl4ai

basher83

This skill should be used when users need to scrape websites, extract structured data, handle JavaScript-heavy pages, crawl multiple URLs, or build automated web data pipelines. Includes optimized extraction patterns with schema generation for efficient, LLM-free extraction.

21137

omero-integration

davila7

Microscopy data management platform. Access images via Python, retrieve datasets, analyze pixels, manage ROIs/annotations, batch processing, for high-content screening and microscopy workflows.

12

kegg-database

davila7

Direct REST API access to KEGG (academic use only). Pathway analysis, gene-pathway mapping, metabolic pathways, drug interactions, ID conversion. For Python workflows with multiple databases, prefer bioservices. Use this for direct HTTP/REST work or KEGG-specific control.

11

reactome-database

davila7

Query Reactome REST API for pathway analysis, enrichment, gene-pathway mapping, disease pathways, molecular interactions, expression analysis, for systems biology studies.

10

youtube-comments-api-skill

aiskillstore

This skill helps users extract structured video list data and comment data from YouTube using the BrowserAct API. The Agent should proactively apply this skill when users request searching for YouTube videos and their comments, analyzing viewer sentiment for a specific video topic, gathering audienc

00

junta-leiloeiros

wegonbeok45

Coleta e consulta dados de leiloeiros oficiais de todas as 27 Juntas Comerciais do Brasil. Scraper multi-UF, banco SQLite, API FastAPI e exportacao CSV/JSON.

00

Search skills

Search the agent skills registry