@wbavon/china-market-data
v0.2.0
Published
Free Chinese market data MCP server — A-shares, indices, fundamentals, sectors. Multi-source with automatic fallback (Tencent/Baostock/Eastmoney/Sina).
Maintainers
Readme
China Market Data
Free Chinese A-share market data service for AI agents. Powered by akshare — data from 东方财富/新浪/同花顺, 100% local.
Architecture
Agent (Claude/Cursor/VS Code)
↓
MCP Server (stdio) CLI (python3 engine/engine.py)
↓ ↓
┌──────────────────────────────────────────┐
│ data_service.py │
│ Stock / Index / Board / Macro / Screener│
└────────────────┬─────────────────────────┘
↓
akshare (Python lib)
┌────┬────┬─────┐
东方财富 新浪 同花顺 ...Quick Start
Note: On macOS/Linux use
python3andpip3; on Windows usepythonandpip.
# Install dependencies
pip install -r engine/requirements.txt
# Initialize database (optional)
python engine/engine.py init
# Query real-time quote
python engine/engine.py stock --symbol 600519
# Historical K-line
python engine/engine.py hist 600519 --start 20240101 --period daily
# Fundamentals
python engine/engine.py info 600519
# Screen stocks
python engine/engine.py screener --min-pe 5 --max-pe 20
# Industry ranking
python engine/engine.py board-industry
# Macro
python engine/engine.py macro cpiMCP Server
Add to your MCP client config (Claude Desktop / Cursor / VS Code):
macOS / Linux:
{
"mcpServers": {
"china-market-data": {
"command": "python3",
"args": ["/path/to/china-market-data/mcp_server.py"]
}
}
}Windows:
{
"mcpServers": {
"china-market-data": {
"command": "python",
"args": ["C:\\path\\to\\china-market-data\\mcp_server.py"]
}
}
}Available Tools
| Tool | Description |
|------|-------------|
| market_stock_quotes | Single stock real-time quote |
| market_market_quotes | All A-share market quotes |
| market_stock_history | Historical K-line data |
| market_stock_info | Company basic info |
| market_stock_financials | Financial statements |
| market_index_history | Index historical data |
| market_indices | Major indices real-time |
| market_board_industry | Industry sector ranking |
| market_board_concept | Concept sector ranking |
| market_board_flow | Sector capital flow |
| market_stock_fund_flow | Stock capital flow |
| market_screener | Stock screener (PE/market cap/industry) |
| market_industries | List industry classifications |
| market_macro | Macroeconomic indicators (GDP/CPI/PPI/M2) |
CLI Commands
python engine/engine.py stock --symbol 600519 # 实时行情
python engine/engine.py hist 600519 --start 20240101 # 历史K线
python engine/engine.py info 600519 # 基本信息
python engine/engine.py financials 600519 --type 利润表 # 财报
python engine/engine.py index-hist 000001 # 指数历史
python engine/engine.py indices # 主要指数
python engine/engine.py board-industry # 行业排行
python engine/engine.py board-concept # 概念排行
python engine/engine.py board-flow --type industry # 资金流向
python engine/engine.py fund-flow 600519 # 个股资金流
python engine/engine.py screener --min-pe 5 --max-pe 20 # 选股
python engine/engine.py industries # 行业列表
python engine/engine.py macro cpi # CPI
python engine/engine.py macro gdp # GDPRequirements
- Python 3.9+
- akshare>=1.10.0
- pandas>=2.0.0
- baostock>=0.8.8
- requests, numpy (akshare deps)
- Supported platforms: macOS, Linux, Windows
Data Sources
Multi-source with automatic fallback:
| Data Type | Primary | Fallback | Last Resort | |-----------|---------|----------|-------------| | Historical K-line | Tencent Finance | Baostock | akshare | | Real-time Quotes | Eastmoney | Sina Finance | — | | Sector/Board | akshare (Eastmoney) | — | — | | Financials | akshare (Sina) | — | — | | Macro | akshare | — | — |
Three-tier cache: Memory (hot) → File (warm) → Network (cold). Stale file cache serves as fallback when all sources fail.
Data Storage
SQLite at ~/.chinamarket/data/market.db (macOS/Linux) or %USERPROFILE%\.chinamarket\data\market.db (Windows). Auto-created on first use.
License
MIT
