Content
# xtquantai
xtquantai is a server based on the Model Context Protocol (MCP) that integrates the functionality of the xtquant quantitative trading platform with an AI assistant, enabling AI to directly access and operate quantitative trading data and functions.
[](https://www.python.org/downloads/)
[](LICENSE)
## Features
XTQuantAI provides the following core features (continuously updated, welcome to submit new ideas):
### Basic Data Query
- **Get Trading Dates** (`get_trading_dates`) - Get trading dates for a specified market
- **Get Sector Stock List** (`get_stock_list`) - Get a list of stocks for a specific sector
- **Get Instrument Details** (`get_instrument_detail`) - Get detailed information about a stock
### Market Data
- **Get Historical Market Data** (`get_history_market_data`) - Get historical market data for a stock
- **Get Latest Market Data** (`get_latest_market_data`) - Get the latest market data for a stock
- **Get Full Market Data** (`get_full_market_data`) - Get complete market data for a stock
### Charts and Visualization
- **Create Chart Panel** (`create_chart_panel`) - Create a stock chart panel with various technical indicators
- **Create Custom Layout** (`create_custom_layout`) - Create a custom chart layout with specified indicator names, parameter names, and parameter values
## Installation
⚠️ Note
1. The QMT ecosystem currently only supports Windows, so the following implementations are in a Windows environment.
2. There are many details in the MCP implementation in the Windows environment that need attention.
### Prerequisites
- Python 3.11 or higher
- xtquant QMT or Trading Terminal
- [uv](https://github.com/astral-sh/uv) package manager (recommended)
### Installation and Precautions for uv
uv is a tool used to start packages, so we need to install it at the beginning. Note that you need to install it in the environment where you will run xtquantai. This is the first possible issue, so if you're unsure, just install it.
```python
pip install uv
```
The second point to note is that uv has a cache, so I have a `clear_cache_and_run.py` file. If you run it incorrectly in the middle, it won't update without deleting the cache, so remember to run it to delete.
### Download
```bash
git clone https://github.com/dfkai/xtquantai.git
```
Or directly download the zip file. You can download it to any folder as long as you can find the specific address of xtquantai later. It's best to go to the folder and copy the address directly.
## Usage
### Integration with Cursor
#### Windows (QMT/Trading Terminal currently only supports Windows, requires Windows environment)
Configure the MCP server in Cursor:
Method 1:
Create a `.cursor` folder in the current project and a `mcp.json` file in that folder. The Cursor editor will automatically add the MCP tool.
```json
{
"mcpServers": {
"xtquantai": {
"command": "cmd /c uvx",
"args": [
"path:\\to\\xtquantai"
]
}
}
}
```
> ⚠️ Note: In Windows, the command must be preceded by `cmd /c`, otherwise, the command window will close immediately after execution.
Method 2:
Directly go to `Settings-MCP-Add new MCP Server`, name it `xtquantai`, and set the command to: `cmd /c uvx path:\to\xtquantai`, and adjust it to `Enabled`.
Note that `path to` refers to your local address, and when you manually fill it in, use a single slash, and only use two slashes in the JSON file to prevent escaping.
## Tool Usage Examples
### Get Trading Dates
```python
# Get trading dates for the Shanghai market
dates = get_trading_dates(market="SH")
```
### Get Stock List
```python
# Get the stock list for the A-share sector
stocks = get_stock_list(sector="沪深A股")
```
### Create Chart Panel
```python
# Create a chart panel with the MA indicator
result = create_chart_panel(
codes="000001.SZ,600519.SH",
period="1d",
indicator_name="MA",
param_names="period",
param_values="5"
)
```
## Development
### Start Server Directly
```bash
# Run directly using Python
python -m xtquantai
# Or use the installed command-line tool
xtquantai
```
### Debugging with MCP Inspector (only during development)
Requires a Node environment.
```bash
npx @modelcontextprotocol/inspector uv run xtquantai
```
### Build and Publish
Prepare the release package:
1. Synchronize dependencies and update the lock file:
```bash
uv sync
```
2. Build the package:
```bash
uv build
```
3. Publish to PyPI:
```bash
uv publish
```
### Debugging
Since the MCP server runs through standard input/output, debugging can be challenging. We strongly recommend using [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for debugging.
## Project Structure
```
xtquantai/
├── src/
│ └── xtquantai/
│ ├── __init__.py # Package initialization file
│ └── server.py # MCP server implementation
├── main.py # Startup script
├── server_direct.py # Direct HTTP server implementation
├── pyproject.toml # Project configuration
└── README.md # Project documentation
```
## License
This project uses the MIT License - see [LICENSE](LICENSE) file.
## Contribution
Contributions are welcome! Please submit issues or pull requests.
## Acknowledgements
- [xtquant Technology](https://www.thinktrader.net/) for providing the quantitative trading platform
- [Model Context Protocol](https://modelcontextprotocol.io/) for providing the AI integration framework
Connection Info
You Might Also Like
Vibe-Trading
Vibe-Trading: Your Personal Trading Agent
valuecell
Valuecell is a Python project for efficient data management.
hexstrike-ai
HexStrike AI is an AI-powered MCP cybersecurity automation platform with 150+ tools.
tradingview-mcp
AI-assisted TradingView chart analysis — connect Claude Code to your...
AP2
AP2 provides code samples and demos for the Agent Payments Protocol.
tradingview-mcp
TradingView MCP Server offers real-time market analysis for crypto and stocks.