Quant Data MCP Server
MCP Server for Quant Data API.
让 Claude Desktop / Cursor 等 MCP 客户端能直接调 A 股数据、跑回测、生成策略代码。
✨ 功能
- 📈 个股实时行情
- 📊 个股 K 线
- 📉 市场统计
- 🏭 行业涨跌幅
- 🔍 多条件选股
- 💰 财务指标(最新 + 历史)
- 🧮 多因子综合排名
- ⚙️ 策略回测(单股 / 多股)
- 🔧 参数自动寻优(网格搜索最佳止损/止盈)
- 🤖 AI 生成策略代码(自然语言 → Python / Java)
- 🎯 组合分析(一次调用返回行情 + 财务 + 因子 + 技术信号)
📦 安装
pip install zizhenghua-mcp
或从源码:
bash
git clone https://github.com/Zizhenghua/quant-data-mcp.git
cd quant-data-mcp
pip install -e .
🚀 配置
Claude Desktop
编辑配置文件:
Windows:%APPDATA%\Claude\claude_desktop_config.json
Mac:~/Library/Application Support/Claude/claude_desktop_config.json
内容:
json
{
"mcpServers": {
"quant-data": {
"command": "python",
"args": ["-m", "quant_data_mcp.server"],
"env": {
"QUANT_API_KEY": ""
}
}
}
}
Cursor
在 Cursor 设置里加 MCP Server,或编辑 ~/.cursor/mcp.json:
json
{
"mcpServers": {
"quant-data": {
"command": "python",
"args": ["-m", "quant_data_mcp.server"],
"env": {
"QUANT_API_KEY": ""
}
}
}
}
🔑 用 API Key
默认匿名调用(10 次/分钟)。
想提高限额,在配置里填 QUANT_API_KEY:
json
{
"env": {
"QUANT_API_KEY": "your_api_key_here"
}
}
注册获取 API Key:https://zizhenghua.com
💬 示例
配好后,在 Claude Desktop / Cursor 里问:
数据查询
"茅台现在多少钱?"
"帮我看看 600519 最近的 K 线"
"今天市场涨跌家数怎么样?"
"哪些行业今天涨得最好?"
"帮我筛选换手率大于 5% 的股票"
"600519 最新的财务指标是什么?"
"600519 最近 8 期 ROE 趋势如何?"
回测与策略
"帮我回测茅台 2024 年双均线策略"
"对比一下 600519 和 000001 的 MACD 策略表现"
"帮我找茅台 KDJ 策略的最佳止损止盈参数"
"写一个布林带回测策略的 Python 代码"
综合分析
"分析一下茅台当前的技术面和基本面"
AI 会自动调对应的工具。
🛠️ 可用工具
工具 说明 类型
get_stock_realtime 个股实时行情 数据
get_stock_kline 个股 K 线 数据
get_market_stats 市场统计 数据
get_sector_performance 行业涨跌幅 数据
filter_stocks 多条件选股 数据
get_fin_latest 最新财务指标 数据
get_fin_history 财务历史(N 期) 数据
get_factor_ranking 多因子综合排名 数据
run_backtest 单股策略回测 回测
run_multi_backtest 多股批量回测 回测
auto_tune 参数自动寻优 回测
generate_strategy_code AI 生成策略代码 AI
analyze_stock 组合分析(行情+财务+因子+信号) 组合
🧪 开发
bash
# 1. Clone
git clone https://github.com/Zizhenghua/quant-data-mcp.git
cd quant-data-mcp
# 2. 虚拟环境
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Mac / Linux
# 3. 安装
pip install -e ".[dev]"
# 4. 设置 API Key(可选,不设则匿名调用)
$env:QUANT_API_KEY="your_key" # Windows
# export QUANT_API_KEY="your_key" # Mac / Linux
# 5. 跑测试
python test_tools.py
# 6. 启动 MCP Server(stdio 模式,需客户端连接)
python -m quant_data_mcp.server
💬 讨论
有问题?来 GitHub Discussions 提问。
📚 相关项目
quant-data-sdk — Python / JS SDK
Quant Data API — 数据接口
📄 License
MIT
Metadata
Release files for zizhenghua-mcp 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zizhenghua_mcp-1.1.0.tar.gz | 9.9 kB | Without provenance | Details for zizhenghua_mcp-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zizhenghua_mcp-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for zizhenghua_mcp-1.1.0-py3-none-any.whl |
Total release size: 18.7 kB
Release files / zizhenghua_mcp-1.1.0.tar.gz
| Download URL | zizhenghua_mcp-1.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
249a2c32cbf0a2e1f4995910799bf40506d420e5ffaf30ed7f6d77fb856f4c78
|
|
BLAKE2b-256 checksum How to use checksums |
ce15188474c31cdd5b18a6b39b74cec3c488f12648a49d89623ab713f81026a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / zizhenghua_mcp-1.1.0-py3-none-any.whl
| Download URL | zizhenghua_mcp-1.1.0-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5848f610e21ef7598dbe6751bcfd1c51c58ff9a10210b15f955f21dd23774a37
|
|
BLAKE2b-256 checksum How to use checksums |
ece84415dfe57a76b7f9ceab63411cb889227b3d20e8d0327c25ed32ce64c375
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for zizhenghua-mcp 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.