Назад към всички

allstock-data

// Stock market data query skill for China A-shares, Hong Kong, and US markets. Uses Tencent Finance HTTP API by default (lightweight, no install needed), with optional adata SDK for more comprehensive data. Supports real-time quotes, K-line history, order book analysis, and more.

$ git log --oneline --stat
stars:1,933
forks:367
updated:March 4, 2026
SKILL.mdreadonly
SKILL.md Frontmatter
nameallstock-data
descriptionStock market data query skill for China A-shares, Hong Kong, and US markets. Uses Tencent Finance HTTP API by default (lightweight, no install needed), with optional adata SDK for more comprehensive data. Supports real-time quotes, K-line history, order book analysis, and more.

Stock Data Query

Two data sources are supported. Tencent Finance HTTP API is used by default:

  1. Tencent Finance HTTP API (Default) — Lightweight, no installation, no proxy required
  2. adata SDK (Optional) — More comprehensive data, requires installation and possibly a proxy

1. Tencent Finance HTTP API (Default)

1.1 China A-Share Real-Time Quotes

Endpoint:

http://qt.gtimg.cn/q=<stock_code>

Stock Code Format:

MarketCode PrefixExample
Shanghai Main Boardsh600xxxsh600519 (Moutai)
STAR Marketsh688xxxsh688111
Shenzhen Main Boardsz000xxxsz000001 (Ping An Bank)
ChiNext (GEM)sz300xxxsz300033
ETFsz159xxxsz159919

Index Codes:

IndexCode
SSE Composite (Shanghai)sh000001
SZSE Component (Shenzhen)sz399001
ChiNext Indexsz399006
STAR 50sz399987
CSI 300sh000300

Examples:

# Single stock
curl -s "http://qt.gtimg.cn/q=sh600519"

# Multiple stocks
curl -s "http://qt.gtimg.cn/q=sh600519,sh000001,sz399001"

Response Fields:

v_sh600519="1~贵州茅台~600519~1460.00~1466.21~1466.99~14146~6374~7772~..."
          ~  Name    ~ Code  ~  Open  ~  High  ~   Low  ~ Volume
IndexField
0Market code
1Stock name
2Stock code
3Current price
4Open price
5Low price
6High price
30Price change
31Change %

1.2 Hong Kong Stock Real-Time Quotes

Endpoint:

http://qt.gtimg.cn/q=hk<stock_code>

Examples:

# Tencent Holdings
curl -s "http://qt.gtimg.cn/q=hk00700"

# Alibaba
curl -s "http://qt.gtimg.cn/q=hk09988"

1.3 US Stock Real-Time Quotes

Endpoint:

http://qt.gtimg.cn/q=us<ticker>

Examples:

# Apple
curl -s "http://qt.gtimg.cn/q=usAAPL"

# Tesla
curl -s "http://qt.gtimg.cn/q=usTSLA"

# NVIDIA
curl -s "http://qt.gtimg.cn/q=usNVDA"

1.4 K-Line Historical Data

Endpoint:

https://web.ifzq.gtimg.cn/appstock/app/fqkline/get

Parameters:

ParameterDescription
_varVariable name, e.g. kline_dayqfq
paramstock_code, kline_type, start_date, end_date, count, adjust_type

K-Line Types: day / week / month

Adjustment Types: qfqa (forward-adjusted) / qfq (backward-adjusted) / empty (unadjusted)

Examples:

# Moutai daily K-line (last 10 days, forward-adjusted)
curl -s "https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_dayqfq&param=sh600519,day,,,10,qfqa"

# Ping An Bank weekly K-line (last 5 weeks)
curl -s "https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_weekqfq&param=sz000001,week,,,5,qfqa"

# ChiNext Index monthly K-line (last 3 months)
curl -s "https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_monthqfq&param=sz399006,month,,,3,qfqa"

Response Format:

{"day": [["2026-02-27", "1466.99", "1461.19", "1476.21", "1456.01", "13534"], ...]}
                Date       Open      Close      High       Low      Volume

1.5 Order Book Analysis

Endpoint:

http://qt.gtimg.cn/q=s_pk<stock_code>

Example:

curl -s "http://qt.gtimg.cn/q=s_pksh600519"

Returns: Buy/sell volume ratios (internal vs external trades)


2. adata SDK (Optional)

adata is an open-source A-share quantitative data library providing more comprehensive data. Requires installation and possibly a proxy.

Installation

pip install adata

Proxy Setup (if needed)

import adata
adata.proxy(is_proxy=True, ip='your-proxy-ip:port')

Feature List

FeatureDescription
Stock Basic InfoAll A-share codes, share capital, SW industry classification
K-Line DataDaily/Weekly/Monthly, forward/backward adjustment
Real-Time QuotesBatch real-time pricing
Level-2 Order BookBid/ask depth data
Capital FlowIndividual stock capital flow analysis
Concept SectorsThematic sector data
Index DataMajor index quotes
ETFETF quotes

Usage Examples

import adata

# Get all A-share stock codes
df = adata.stock.info.all_code()

# Get K-line data
df = adata.stock.market.get_market(
    stock_code='000001',
    k_type=1,           # 1=daily, 2=weekly, 3=monthly
    start_date='2024-01-01',
    adjust_type=1        # 0=unadjusted, 1=forward, 2=backward
)

# Real-time quotes
df = adata.stock.market.list_market_current(
    code_list=['000001', '600519']
)

3. Use Case Guide

ScenarioRecommended Source
Quick single stock price checkTencent Finance API
K-line historical dataTencent Finance API
Batch quote queriesTencent Finance API
Capital flow dataadata SDK
Full financial statementsadata SDK
Concept/sector analysisadata SDK
Level-2 order bookTencent Finance API or adata SDK

4. Important Notes

  1. Encoding: Tencent Finance API returns GBK-encoded text — decode accordingly
  2. Change %: Use the API's built-in field (index 31) — do not calculate manually
  3. Data Delay: Real-time data may have up to 15-minute delay
  4. Request Rate: Avoid high-frequency requests — use batch queries when possible
  5. Error Handling: Invalid stock codes return v_pv_none_match="1"