Fetch real-time (or near-real-time) and historical stock market data for any stock symbol across:
Data is sourced from 东方财富 (Eastmoney) and 新浪财经 (Sina Finance) public APIs — no API key required.
Load this skill when the user asks about:
Determine the stock code and market from the user's input.
Use the auto-detection logic in the script, or ask if ambiguous:
| Code pattern | Market |
|---|---|
| 6-digit starting with 6 | 沪市 (sh) |
| 6-digit starting with 00 or 30 | 深市 (sz) |
| 5-digit number | 港股 (hk) |
| Uppercase letters only | 美股 (us) |
For well-known names (e.g., "中航成飞", "贵州茅台", "腾讯"), resolve to code before running.
Execute the fetch script for live data:
python scripts/fetch_stock.py <CODE> [--market sh|sz|hk|us] [--json]
Examples:
python scripts/fetch_stock.py 302132 # 中航成飞
python scripts/fetch_stock.py 600519 # 贵州茅台
python scripts/fetch_stock.py 00700 --market hk # 腾讯控股
python scripts/fetch_stock.py AAPL --market us # 苹果
python scripts/fetch_stock.py 302132 --json # JSON output
Execute the history script for past data:
python scripts/fetch_history.py <CODE> [--start YYYYMMDD] [--end YYYYMMDD] [--period daily|weekly|monthly] [--market sh|sz|hk|us] [--json]
Examples:
# Default: last 6 months daily
python scripts/fetch_history.py 302132
# Custom date range
python scripts/fetch_history.py 302132 --start 20260101 --end 20260325
# Weekly K-line
python scripts/fetch_history.py 600519 --period weekly --start 20250901
# Hong Kong stock
python scripts/fetch_history.py 00700 --market hk --start 20260101
# US stock
python scripts/fetch_history.py AAPL --market us --start 20260101
# JSON output (for programmatic use)
python scripts/fetch_history.py 302132 --start 20260101 --json
The scripts are located at: ~/.workbuddy/skills/stock-realtime-data/scripts/
For real-time quotes, present:
For historical data, present:
Always append: ⚠️ 数据仅供参考,不构成投资建议。
If a script fails (network error, unsupported code, market closed):
See references/api_reference.md for:
共 2 个版本