SuperAPI AI Directory

a-share-data

Data & analytics

View repository

Updated 10-16 06:49

About this skill

A-share data comprehensive analysis

Goal

When using this skill, prioritize calling the scripts in this directory to obtain structured data; do not rely on web scraping.

Supported capabilities:

  • Real-time quotes and market dimensions
  • Historical data and financial dimensions
  • Technical indicators
  • Individual stock events
  • List of A+H dual-listed companies (supports filtering by H-share listing date)
  • Key event time points for A-share companies listing in Hong Kong (filing/listening/record-filing/IPO/pricing/placement/listing)
  • Hot industries, hot concepts, industry/concept gain/loss, sector heatmaps, sector constituent stocks, 7×24 market news flashes (fetch_danginvest.py;Read first references/danginvest-api-reference.md)
  • Individual stock industry information (fetch_sector_info.py, data source Eastmoney;Individual stock conceptsunstable, see below)

Environment and paths

pip install akshare MyTT pandas numpy requests
SKILL_DIR="<本skill绝对路径>"
python3 "$SKILL_DIR/scripts/fetch_realtime.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_history.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_technical.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_stock_events.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_ah_stocks.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_ah_ipo_timeline.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_danginvest.py" [参数]
python3 "$SKILL_DIR/scripts/fetch_sector_info.py" [参数]

Note:fetch_sector_info.py Although it may carry concept parameters, Eastmoneyindividual stock conceptsinterface is unstable and often empty; when using, always add --no-concepts, and only query industry and securities abbreviation.Market-level concept sectors(gain/loss, heatmaps, constituent stocks) go through fetch_danginvest.py, do not mix with the former.

Code format conventions

Prefer the following stock code formats:

  • Pure numbers:600519
  • Market prefix:sh600519 / sz000001
  • JoinQuant:600519.XSHG

Script routing rules

Choose scripts by question type:

  • fetch_danginvest.py:Hot concepts, hot industries, industry gain/loss, concept gain/loss, sector heatmaps, sector constituent stocks, 7×24 market news flashes; for parameters and query conventions see references/danginvest-api-reference.md
  • fetch_realtime.py: real-time prices, minute bars, indices, northbound, dragon-tiger list, limit up/down, capital flows, whole-market quotes, trade details (--boards-* only compatible with legacy usage)
  • fetch_history.py: historical K-lines, financials, performance, dividends, industry, index constituents, trading calendar, macro
  • fetch_technical.py: MA/MACD/KDJ/RSI/BOLL and other technical indicators
  • fetch_stock_events.py: performance, increases/decreases in holdings/buybacks, regulation, major contracts, public opinion direction
  • fetch_ah_stocks.py: A+H dual-listed company list, H-share listing date range filtering
  • fetch_ah_ipo_timeline.py: key event nodes for A-share companies listing in Hong Kong (filing/listening/record-filing/IPO/pricing/placement/listing); supports --code / --name point query
  • fetch_sector_info.py: industry and name of a single or multiple stocks (Eastmoney); parallel in batch, default --workers;only document the industry path, do not add concepts

Execution flow

  1. First identify user intent: real-time, historical, technical, events, A-share Hong Kong listing time nodes,hot industries/hot concepts/industry or concept gain/loss, sector heatmaps, 7×24 news flashes, or "industry the stock belongs to".
  2. When any of the following expressions is matched,read first references/danginvest-api-reference.md, then use fetch_danginvest.py(do not use fetch_realtime.py --boards-*):
    • today/current dayhot concepts, which concepts rose the most, concept leaders/laggards
    • Today/todayHot industries, which industries rose the most, industry leaders/laggards (including major industry categories and sub-industries)
    • Industry gain/loss、Concept gain/loss, sector heatmap, constituent stocks of a sector
    • 7×24 market newsflash
  3. Select the corresponding script and prioritize adding --json。
  4. When parameters are insufficient, fill in default values and then execute; do not just talk without acting.
  5. When returning, provide conclusions on key fields and include reproducible commands.

Degradation and fault-tolerance rules

  • Historical capabilities uniformly go through fetch_history.py(multi-source logic is already built in; the K-line chain prioritizes Tencent, degrades to Sina, and falls back to Eastmoney).
  • When encountering upstream rate limiting or temporary failure:
    • For similar interfaces, retry 1-2 times first.
    • Degrade if possible; if degradation is not possible, clearly mark it as "upstream data source unavailable".
  • --all-stocks Already supports multiple sources from Sina/Tencent/Xueqiu; if a single source fails, continue returning merged results from other sources.

Batch data parallelism and timeout specifications (mandatory)

When the task is "batch fetching" (real-time stock list / multiple historical K-lines), default to parallel, not one-by-one serial.

  • Recommended concurrency:max_workers=8~12(default 10)
  • Capture exceptions independently for each stock; failures do not block the entire batch
  • Result output must include: sample size, success rate, total elapsed time, list of failed codes

Timeout upper limit (hard limit):

  • Batch real-time stock list: the entire batch task waits at most 30s
  • Batch historical K-lines (multiple stocks): the entire batch task waits at most 30s
  • Full-market concurrent task: the entire batch task waits at most 60s

Timeout/failure handling (mandatory):

  • When the timeout is reached, stop waiting and return the current results
  • If it fails, mark it as failed; do not perform long blocking retries
  • Unlimited retries or "getting stuck and waiting forever" are prohibited

Output specifications

  • By default, return structured key points; do not pile up long tables.
  • Return the complete JSON only when raw data is needed.
  • Clearly specify the data source and time point (such as trading day, update time, intraday/closed status).

Minimal set of common commands

# 实时(单只)
python3 fetch_realtime.py --quote 600519 --json
# 实时(多只,逗号分隔,最多10只)
python3 fetch_realtime.py --multi-quote 002491,002364,600519 --json
python3 fetch_realtime.py --index --json
python3 fetch_realtime.py --all-quote --sort change_pct_desc --top 50 --json
python3 fetch_realtime.py --tick 600519 --json

# 历史
python3 fetch_history.py --kline 600519 --start 2025-01-01 --end 2025-03-31 --freq d --json
python3 fetch_history.py --kline-batch 600519,000001,300750 --start 2025-10-01 --end 2026-03-31 --count 120 --workers 8 --retries 2 --json
python3 fetch_history.py --financials 600519 --start 2023-01-01 --end 2025-01-01 --json
python3 fetch_history.py --industry 300271 --with-boards --json

# 技术
python3 fetch_technical.py 600519 --freq 1d --count 120 --indicators MA,MACD,KDJ,RSI,BOLL --json

# 事件
python3 fetch_stock_events.py --code 300476 --name 胜宏科技 --dates 20250331,20241231 --limit 20 --json

# A+H 列表
python3 fetch_ah_stocks.py --json
python3 fetch_ah_stocks.py --since 2020-01-01 --until 2024-12-31 --json

# A股赴港上市关键节点
python3 fetch_ah_ipo_timeline.py --name 顺丰 --json
python3 fetch_ah_ipo_timeline.py --code 002352 --json
python3 fetch_ah_ipo_timeline.py --since 2020 --workers 4 --json

# 热门行业/热门概念/涨跌幅/快讯 → fetch_danginvest.py,见 references/danginvest-api-reference.md

# 个股行业(不加概念,见上文说明)
python3 fetch_sector_info.py --no-concepts --json 600519
python3 fetch_sector_info.py --workers 8 --no-concepts --timeout 15 --json 600519 000001 300750 600036 601318 002594 688981 300059

Things not to do

  • Do not treat this skill as the preferred solution for crawler tasks.
  • Do not output extremely long raw tables when unnecessary.
  • Do not use removed old workflow wording.
  • Hot concepts, hot industries, industry/concept gain/loss, sector heatmap, sector constituents, market newsflash: use fetch_danginvest.py,read first references/danginvest-api-reference.md; do not use fetch_realtime.py --boards-*。
  • Do not promise fetch_sector_info.py 's individual stock concept field; market-level "hot concepts/concept gain/loss" go through fetch_danginvest.py, not sector_info.

Reference

  • Script parameters such as real-time/historical/technical:references/api-reference.md
  • Hot industries, hot concepts, industry/concept gain/loss, heatmap, constituent stocks, newsflash(trigger words, which dimensions are queried by default, command examples):references/danginvest-api-reference.md
  • GitHub project address:https://github.com/shouldnotappearcalm/a-share-skill