| name | stock-price |
| description | Query A-share, Hong Kong stock, ETF, and index real-time quotes (latest price, change %, volume, etc.). Uses Tencent market API (qt.gtimg.cn), no login or API Key required. Triggered when user says "check stock price", "real-time quote", "ETF price", "stock market", "index level".
|
| version | 1.0.0 |
Real-time Stock/ETF/Index Quote Query
Data Sources (by priority)
| Priority | Data Source | Characteristics |
|---|
| Primary | Tencent Market API (qt.gtimg.cn) | Fastest, one curl gets all data, no login |
| Backup | Sina Finance (gu.sina.cn) | Shows major indices on homepage, top 6 hot sectors |
| Backup | East Money (data.eastmoney.com/bkzj/hy.html) | Sector fund flows, requires desktop UA |
Tencent Market API (Primary)
Request Format
curl -s "qt.gtimg.cn/q=<code list, comma separated>"
Stock Code Format
| Market | Format | Example |
|---|
| Shanghai A-shares | sh + 6-digit code | sh600519 (Kweichow Moutai) |
| Shenzhen A-shares | sz + 6-digit code | sz000001 (Ping An Bank) |
| Hong Kong stocks | hk + 5-digit code | hk00700 (Tencent Holdings) |
| Shanghai Composite | sh000001 | SSE Composite Index |
| ChiNext Index | sz399006 | ChiNext Index |
Response Format
Response text is separated by :
v_="1~..."
Key field indices (~ separated, starting from 0):
- 1: Name
- 3: Latest price
- 32: Change (%)
- 6: Volume (lots)
- 7: Turnover (yuan)
Example
curl -s "qt.gtimg.cn/q=sh000001,sz399006,sh588170,hk00700"
Python parsing example:
fields = line.split('="')[1].rstrip('";').split('~')
name = fields[1]
price = fields[3]
change_pct = fields[32]
Sina Finance (Backup)
navigate: https://gu.sina.cn
get_readable: extract major indices, hot sectors, advancing/declining count
Report Format
Shanghai Composite: 4068.57 (-0.73%)
ChiNext Index: 2140.32 (+0.85%)
Notes
- Real-time update during trading hours, shows closing price after market close
- Hong Kong stock free version has 15-minute delay
- Single query should not exceed 20 codes
- Response encoding is GBK