quantconnect-mcp


Namequantconnect-mcp JSON
Version 0.1.11 PyPI version JSON
download
home_pageNone
SummaryAdd your description here
upload_time2025-07-22 22:38:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

# ◆ QuantConnect MCP Server

[![Python](https://img.shields.io/badge/Python-3.12%2B-blue.svg)](https://python.org)
[![FastMCP](https://img.shields.io/badge/FastMCP-v2.7%2B-green.svg)](https://github.com/fastmcp/fastmcp)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Code Style](https://img.shields.io/badge/Code%20Style-Black-black.svg)](https://github.com/psf/black)
[![Type Checked](https://img.shields.io/badge/Type%20Checked-mypy-blue.svg)](https://mypy.readthedocs.io/)

**Production-ready Model Context Protocol server for QuantConnect's algorithmic trading platform**

*Integrate QuantConnect's research environment, statistical analysis, and portfolio optimization into your AI workflows. Locally hosted, secure & capable of dramatically improving productivity*

[◉ Quick Start](#-quick-start) •
[◉ Documentation](#-comprehensive-api-reference) •
[◉ Architecture](#-architecture) •
[◉ Contributing](#-contributing)

</div>

<details open>
<summary>Demo – Claude</summary>

<div align="center">
  <video width="832" src="https://github.com/user-attachments/assets/61e96e0e-05b2-482b-8fe3-ccf078d64cc5"></video>
</div>

</details>


---

## ◈ Is this crazy?
<div align="center">
<img width="25%" height="25%" alt="image" src="https://github.com/user-attachments/assets/f282cb1e-7fde-4efd-b28c-2656c9f48fea" />
</div>
Maybe? Either way, the world is changing and this is where we're at.
Out of the box, QuantConnect MCP provides you with:

- **Full Project Lifecycle**: `Create`, `read`, `update`, `compile`, and manage QuantConnect projects and files programmatically.
- **End-to-End Backtesting**: `Compile` projects, `create backtests`, `read detailed results`, and analyze `charts`, `orders`, and `insights`.
- **Interactive Research**: Full `QuantBook` integration for dynamic financial analysis, including historical and `alternative data` retrieval.
- **Advanced Analytics**: Perform `Principal Component Analysis (PCA)`, `Engle-Granger cointegration tests`, `mean-reversion analysis`, and `correlation studies`.
- **Portfolio Optimization**: Utilize sophisticated `sparse optimization` with Huber Downward Risk minimization, calculate performance, and benchmark strategies.
- **Universe Selection**: Dynamically `screen assets` by multiple criteria, analyze `ETF constituents`, and select assets based on correlation.
- **Enterprise-Grade Security**: Secure, `SHA-256 authenticated` API integration with QuantConnect.
- **High-Performance Core**: Built with an `async-first` design for concurrent data processing and responsiveness.
- **AI-Native Interface**: Designed for seamless interaction via `natural language` in advanced AI clients.

## ◉ Table of Contents

- [◈ Quick Start](#-quick-start)
- [◈ Authentication](#-authentication)
- [◈ Natural Language Examples](#-natural-language-examples)
- [◈ Comprehensive API Reference](#-comprehensive-api-reference)
- [◈ Architecture](#-architecture)
- [◈ Advanced Configuration](#-advanced-configuration)
- [◈ Testing](#-testing)
- [◈ Contributing](#-contributing)
- [◈ License](#-license)

## ◈ Quick Start

Get up and running in under 2 minutes:

> **Prerequisites:** You must have QuantConnect credentials (User ID and API Token) before running the server. The server will not function without proper authentication. See [Authentication](#-authentication) section for details on obtaining these credentials.

### **Install with uvx (Recommended)**
```bash
# Install and run directly from PyPI - no cloning required!
uvx quantconnect-mcp

# Or install with uv/pip
uv pip install quantconnect-mcp
pip install quantconnect-mcp
```


### One-Click Claude Desktop Install (Recommended)

1. **Download:** Grab the latest `quantconnect-mcp.dxt` from the “Releases” page
2. **Install:** Double-click the file – Claude Desktop opens and prompts you to **Install**
3. **Configure:** In Claude Desktop → **Settings → Extensions → QuantConnect MCP**, paste your user ID and API token
4. **Use it:** Start a new Claude chat and call any QuantConnect tool


**Why DXT?**
> Desktop Extensions (`.dxt`) bundle the server, dependencies, and manifest so users go from download → working MCP in **one click** – no terminal, no JSON editing, no version conflicts.

### 2. **Set Up QuantConnect Credentials (Required)**
**The server requires these environment variables to function properly:**
```bash
export QUANTCONNECT_USER_ID="your_user_id"        # Required
export QUANTCONNECT_API_TOKEN="your_api_token"    # Required
export QUANTCONNECT_ORGANIZATION_ID="your_org_id" # Optional
```

### 3. **Launch the Server**
```bash
# STDIO transport (default) - Recommended for MCP clients
uvx quantconnect-mcp

# HTTP transport
MCP_TRANSPORT=streamable-http MCP_PORT=8000 uvx quantconnect-mcp
```

### 4. **Interact with Natural Language**

Instead of calling tools programmatically, you use natural language with a connected AI client (like Claude, a GPT, or any other MCP-compatible interface).

> "Initialize a research environment, add GOOGL, AMZN, and MSFT, then run a PCA analysis on them for 2023."


## ◈ Authentication

### Getting Your Credentials

| Credential | Where to Find | Required |
|------------|---------------|----------|
| **User ID** | Email received when signing up | ◉ Yes |
| **API Token** | [QuantConnect Settings](https://www.quantconnect.com/settings/) | ◉ Yes |
| **Organization ID** | Organization URL: `/organization/{ID}` | ◦ Optional |

### Configuration Methods

#### Method 1: Environment Variables (Recommended)
```bash
# Add to your .bashrc, .zshrc, or .env file
export QUANTCONNECT_USER_ID="123456"
export QUANTCONNECT_API_TOKEN="your_secure_token_here"
export QUANTCONNECT_ORGANIZATION_ID="your_org_id"  # Optional
```

<details open>
<summary>Demo – Roo Code</summary>

<div align="center">
  <video width="832" src="https://github.com/user-attachments/assets/4d0e8074-aa27-4041-befc-b4119b5eaec6"></video>
</div>

</details>

## ◈ Natural Language Examples

This MCP server is designed to be used with natural language. Below are examples of how you can instruct an AI assistant to perform complex financial analysis tasks.

### Factor‑Driven Portfolio Construction Pipeline

> **“Build a global equity long/short portfolio for 2025:**
> 1. Pull the **constituents of QQQ, SPY, and EEM** as of **2024‑12‑31** (survivor‑bias free).
> 2. For each symbol, calculate **Fama‑French 5‑factor** and **quality‑minus‑junk** loadings using daily data **2022‑01‑01 → 2024‑12‑31**.
> 3. Rank stocks into terciles on **value (B/M)** and **momentum (12‑1)**; go long top tercile, short bottom, beta‑neutral to the S&P 500.
> 4. Within each book, apply **Hierarchical Risk Parity (HRP)** for position sizing, capped at **5 % gross exposure per leg**.
> 5. Target **annualised ex‑ante volatility ≤ 10 %**; solve with **CVaR minimisation** under a 95 % confidence level.
> 6. Benchmark against **MSCI World**; report **annualised return, vol, Sharpe, Sortino, max DD, hit‑rate, turnover** for the period **2023‑01‑01 → 2024‑12‑31**.
> 7. Export the optimal weights and full tear‑sheet as `pdf` + `csv`.
> 8. Schedule a monthly rebalance job and push signals to the live trading endpoint.”

---

### Robust Statistical‑Arbitrage Workflow

> **“Test and refine a pairs‑trading idea:**
> • Universe: **US Staples sector, market cap > $5 B, price > $10**.
> • Data: **15‑minute bars, 2023‑01‑02 → 2025‑06‑30**.
> • Step 1 – For all pairs, calculate **rolling 60‑day distance correlation**; keep pairs with dCor ≥ 0.80.
> • Step 2 – Run **Johansen cointegration** (lag = 2) on the survivors; retain pairs with trace‑stat < 5 % critical value.
> • Step 3 – For each cointegrated pair:
>    – Estimate **half‑life of mean‑reversion**; discard if > 7 days.
>    – Compute **Hurst exponent**; require H < 0.4.
> • Step 4 – Simulate a **Bayesian Kalman‑filter spread** to allow time‑varying hedge ratios.
> • Entry: z‑score crosses ±2 (two‑bar confirmation); Exit: z = 0 or t_max = 3 × half‑life.
> • Risk: cap **pair notional at 3 % NAV**, portfolio **gross leverage ≤ 3 ×**, stop‑loss at z = 4.
> • Output: trade log, PnL attribution, **bootstrapped p‑value of alpha**, and **Likelihood‑Ratio test** for regime shifts.”


### Automated Project, Backtest & Hyper‑Parameter Sweep

> **“Spin up an experiment suite in QuantConnect:**
> 1. Create project **‘DynamicPairs_Kalman’** (Python).
> 2. Add files:
>    • `alpha.py` – signal generation (placeholder)
>    • `risk.py` – custom position sizing
>    • `config.yaml` – parameter grid:
>        ```yaml
>        entry_z:  [1.5, 2.0, 2.5]
>        lookback: [30, 60, 90]
>        hedge:    ['OLS', 'Kalman']
>        ```
> 3. Trigger a **parameter‑sweep backtest** labelled **‘GridSearch‑v1’** using **in‑sample 2022‑23**.
> 4. When jobs finish, rank runs by **Information Ratio** and **max DD < 10 %**; persist **top‑3 configs**.
> 5. Automatically launch **out‑of‑sample backtests 2024‑YTD** for the winners.
> 6. Produce an executive summary: tables + charts (equity curve, rolling Sharpe, exposure histogram).
> 7. Package the best model as a **Docker image**, push to registry, and deploy to the **live‑trading cluster** with a kill‑switch if **1‑day loss > 3 σ**.”

### Statistical Analysis Workflow

> "Are Coca-Cola (KO) and Pepsi (PEP) cointegrated? Run the test for the period from 2023 to 2024. If they are, analyze their mean-reversion properties with a 20-day lookback."

### Project and Backtest Management

> "I need to manage my QuantConnect projects. First, create a new Python project named 'My_Awesome_Strategy'. Then, create a file inside it called 'main.py' and add this code: `...your algorithm code here...`. After that, compile it and run a backtest named 'Initial Run'. When it's done, show me the performance results."

## ◈ Comprehensive API Reference

### ◆ Authentication Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `configure_quantconnect_auth` | Set up API credentials | `user_id`, `api_token`, `organization_id` |
| `validate_quantconnect_auth` | Test credential validity | - |
| `get_auth_status` | Check authentication status | - |
| `test_quantconnect_api` | Test API connectivity | `endpoint`, `method` |
| `clear_quantconnect_auth` | Clear stored credentials | - |

### ◆ Project Management Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `create_project` | Create new QuantConnect project | `name`, `language`, `organization_id` |
| `read_project` | Get project details or list all | `project_id` (optional) |
| `update_project` | Update project name/description | `project_id`, `name`, `description` |
| `compile_project` | Compile a project for backtesting | `project_id` |

### ◆ File Management Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `create_file` | Create file in project | `project_id`, `name`, `content` |
| `read_file` | Read file(s) from project | `project_id`, `name` (optional) |
| `update_file_content` | Update file content | `project_id`, `name`, `content` |
| `update_file_name` | Rename file in project | `project_id`, `old_file_name`, `new_name` |

### ◆ QuantBook Research Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `initialize_quantbook` | Create new research instance | `instance_name`, `organization_id`, `token` |
| `list_quantbook_instances` | View all active instances | - |
| `get_quantbook_info` | Get instance details | `instance_name` |
| `remove_quantbook_instance` | Clean up instance | `instance_name` |

### ◆ Data Retrieval Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `add_equity` | Add single equity security | `ticker`, `resolution`, `instance_name` |
| `add_multiple_equities` | Add multiple securities | `tickers`, `resolution`, `instance_name` |
| `get_history` | Get historical price data | `symbols`, `start_date`, `end_date`, `resolution` |
| `add_alternative_data` | Subscribe to alt data | `data_type`, `symbol`, `instance_name` |
| `get_alternative_data_history` | Get alt data history | `data_type`, `symbols`, `start_date`, `end_date` |

### ◆ Statistical Analysis Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `perform_pca_analysis` | Principal Component Analysis | `symbols`, `start_date`, `end_date`, `n_components` |
| `test_cointegration` | Engle-Granger cointegration test | `symbol1`, `symbol2`, `start_date`, `end_date` |
| `analyze_mean_reversion` | Mean reversion analysis | `symbols`, `start_date`, `end_date`, `lookback_period` |
| `calculate_correlation_matrix` | Asset correlation analysis | `symbols`, `start_date`, `end_date` |

### ◆ Portfolio Optimization Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `sparse_optimization` | **Advanced sparse optimization** | `portfolio_symbols`, `benchmark_symbol`, optimization params |
| `calculate_portfolio_performance` | Performance metrics | `symbols`, `weights`, `start_date`, `end_date` |
| `optimize_equal_weight_portfolio` | Equal-weight optimization | `symbols`, `start_date`, `end_date`, `rebalance_frequency` |

### ◆ Universe Selection Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `get_etf_constituents` | Get ETF holdings | `etf_ticker`, `date`, `instance_name` |
| `add_etf_universe_securities` | Add all ETF constituents | `etf_ticker`, `date`, `resolution` |
| `select_uncorrelated_assets` | Find uncorrelated assets | `symbols`, `num_assets`, `method` |
| `screen_assets_by_criteria` | Multi-criteria screening | `symbols`, `min_return`, `max_volatility`, etc. |

### ◆ Backtest Management Tools

| Tool | Description | Key Parameters |
|------|-------------|----------------|
| `create_backtest` | Create new backtest from compile | `project_id`, `compile_id`, `backtest_name` |
| `read_backtest` | Get backtest results | `project_id`, `backtest_id`, `chart` |
| `read_backtest_chart` | Get chart data | `project_id`, `backtest_id`, `name` |
| `read_backtest_orders` | Get order history | `project_id`, `backtest_id`, `start`, `end` |
| `read_backtest_insights` | Get insights data | `project_id`, `backtest_id`, `start`, `end` |

## ◈ Architecture

```
quantconnect-mcp/
├── ◆  quantconnect_mcp/          # Main package directory
│   ├── main.py                   # Server entry point & configuration
│   └── src/                      # Source code modules
│       ├── ⚙  server.py          # FastMCP server core
│       ├── ⚙  tools/             # Tool implementations
│       │   ├── ▪  auth_tools.py      # Authentication management
│       │   ├── ▪  project_tools.py   # Project CRUD operations
│       │   ├── ▪  file_tools.py      # File management
│       │   ├── ▪  quantbook_tools.py # Research environment
│       │   ├── ▪  data_tools.py      # Data retrieval
│       │   ├── ▪  analysis_tools.py  # Statistical analysis
│       │   ├── ▪  portfolio_tools.py # Portfolio optimization
│       │   ├── ▪  universe_tools.py  # Universe selection
│       │   └── ▪  backtest_tools.py  # Backtest management
│       ├── ◆  auth/              # Authentication system
│       │   ├── __init__.py
│       │   └── quantconnect_auth.py   # Secure API authentication
│       └── ◆  resources/         # System resources
│           ├── __init__.py
│           └── system_resources.py   # Server monitoring
├── ◆  tests/                     # Comprehensive test suite
│   ├── test_auth.py
│   ├── test_server.py
│   └── __init__.py
├── ◆  pyproject.toml             # Project configuration
└── ◆  README.md                  # This file
```

### Core Design Principles

- **◎ Modular Architecture**: Each tool category is cleanly separated for maintainability
- **▪ Security First**: SHA-256 authenticated API with secure credential management
- **⚡ Async Performance**: Non-blocking operations for maximum throughput
- **◆ Type Safety**: Full type annotations with mypy verification
- **⚙ Extensible**: Plugin-based architecture for easy feature additions

## ◈ Advanced Configuration

### Environment Variables

| Variable | Description | Default | Example |
|----------|-------------|---------|---------|
| `MCP_TRANSPORT` | Transport method | `stdio` | `streamable-http` |
| `MCP_HOST` | Server host | `127.0.0.1` | `0.0.0.0` |
| `MCP_PORT` | Server port | `8000` | `3000` |
| `MCP_PATH` | HTTP endpoint path | `/mcp` | `/api/v1/mcp` |
| `LOG_LEVEL` | Logging verbosity | `INFO` | `DEBUG` |

### System Resources

You can monitor server performance and status using natural language queries for system resources:

> "Show me the server's system info."

> "What's the current server status and are there any active QuantBook instances?"

> "Give me a summary of all available tools."

> "Get the latest performance metrics for the server."

> "What are the top 10 most resource-intensive processes running on the server?"

## ◈ Testing

### Run the Test Suite

```bash
# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=src --cov-report=html

# Run specific test category
pytest tests/test_auth.py -v

# Run tests in parallel
pytest tests/ -n auto
```


## ◈ Contributing

We welcome contributions! This project follows the highest Python development standards:

### Development Setup

```bash
# Fork and clone the repository
git clone https://github.com/your-username/quantconnect-mcp
cd quantconnect-mcp

# Install development dependencies
uv sync --dev

# Install pre-commit hooks
pre-commit install
```

### Code Quality Standards

- ◉ **Type Hints**: All functions must have complete type annotations
- ◉ **Documentation**: Comprehensive docstrings for all public functions
- ◉ **Testing**: Minimum 90% test coverage required
- ◉ **Formatting**: Black code formatting enforced
- ◉ **Linting**: Ruff linting with zero warnings
- ◉ **Type Checking**: mypy verification required

### Development Workflow

```bash
# Create feature branch
git checkout -b feature/amazing-new-feature

# Make changes and run quality checks
ruff check src/
black src/ tests/
mypy src/

# Run tests
pytest tests/ --cov=src

# Commit with conventional commits
git commit -m "feat: add amazing new feature"

# Push and create pull request
git push origin feature/amazing-new-feature
```

### Pull Request Guidelines

1. **◆ Clear Description**: Explain what and why, not just how
2. **◆ Test Coverage**: Include tests for all new functionality
3. **◆ Documentation**: Update README and docstrings as needed
4. **◆ Code Review**: Address all review feedback
5. **◆ CI Passing**: All automated checks must pass

## ◈ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

<div align="center">

**Built with precision for the algorithmic trading community**

[![Python](https://img.shields.io/badge/Python-3.12%2B-blue.svg)](https://python.org)
[![FastMCP](https://img.shields.io/badge/FastMCP-v2.7%2B-green.svg)](https://github.com/fastmcp/fastmcp)
[![QuantConnect](https://img.shields.io/badge/QuantConnect-API%20v2-orange.svg)](https://www.quantconnect.com)

[◉ Star this repo](https://github.com/your-org/quantconnect-mcp) •
[◉ Report issues](https://github.com/your-org/quantconnect-mcp/issues) •
[◉ Request features](https://github.com/your-org/quantconnect-mcp/discussions)

</div>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "quantconnect-mcp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/40/ca/b5e41680c94bad43c72c6eb2c9becd94fd65c2da3855fb2d5602dfe2c749/quantconnect_mcp-0.1.11.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n# \u25c6 QuantConnect MCP Server\n\n[![Python](https://img.shields.io/badge/Python-3.12%2B-blue.svg)](https://python.org)\n[![FastMCP](https://img.shields.io/badge/FastMCP-v2.7%2B-green.svg)](https://github.com/fastmcp/fastmcp)\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Code Style](https://img.shields.io/badge/Code%20Style-Black-black.svg)](https://github.com/psf/black)\n[![Type Checked](https://img.shields.io/badge/Type%20Checked-mypy-blue.svg)](https://mypy.readthedocs.io/)\n\n**Production-ready Model Context Protocol server for QuantConnect's algorithmic trading platform**\n\n*Integrate QuantConnect's research environment, statistical analysis, and portfolio optimization into your AI workflows. Locally hosted, secure & capable of dramatically improving productivity*\n\n[\u25c9 Quick Start](#-quick-start) \u2022\n[\u25c9 Documentation](#-comprehensive-api-reference) \u2022\n[\u25c9 Architecture](#-architecture) \u2022\n[\u25c9 Contributing](#-contributing)\n\n</div>\n\n<details open>\n<summary>Demo \u2013 Claude</summary>\n\n<div align=\"center\">\n  <video width=\"832\" src=\"https://github.com/user-attachments/assets/61e96e0e-05b2-482b-8fe3-ccf078d64cc5\"></video>\n</div>\n\n</details>\n\n\n---\n\n## \u25c8 Is this crazy?\n<div align=\"center\">\n<img width=\"25%\" height=\"25%\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f282cb1e-7fde-4efd-b28c-2656c9f48fea\" />\n</div>\nMaybe? Either way, the world is changing and this is where we're at.\nOut of the box, QuantConnect MCP provides you with:\n\n- **Full Project Lifecycle**: `Create`, `read`, `update`, `compile`, and manage QuantConnect projects and files programmatically.\n- **End-to-End Backtesting**: `Compile` projects, `create backtests`, `read detailed results`, and analyze `charts`, `orders`, and `insights`.\n- **Interactive Research**: Full `QuantBook` integration for dynamic financial analysis, including historical and `alternative data` retrieval.\n- **Advanced Analytics**: Perform `Principal Component Analysis (PCA)`, `Engle-Granger cointegration tests`, `mean-reversion analysis`, and `correlation studies`.\n- **Portfolio Optimization**: Utilize sophisticated `sparse optimization` with Huber Downward Risk minimization, calculate performance, and benchmark strategies.\n- **Universe Selection**: Dynamically `screen assets` by multiple criteria, analyze `ETF constituents`, and select assets based on correlation.\n- **Enterprise-Grade Security**: Secure, `SHA-256 authenticated` API integration with QuantConnect.\n- **High-Performance Core**: Built with an `async-first` design for concurrent data processing and responsiveness.\n- **AI-Native Interface**: Designed for seamless interaction via `natural language` in advanced AI clients.\n\n## \u25c9 Table of Contents\n\n- [\u25c8 Quick Start](#-quick-start)\n- [\u25c8 Authentication](#-authentication)\n- [\u25c8 Natural Language Examples](#-natural-language-examples)\n- [\u25c8 Comprehensive API Reference](#-comprehensive-api-reference)\n- [\u25c8 Architecture](#-architecture)\n- [\u25c8 Advanced Configuration](#-advanced-configuration)\n- [\u25c8 Testing](#-testing)\n- [\u25c8 Contributing](#-contributing)\n- [\u25c8 License](#-license)\n\n## \u25c8 Quick Start\n\nGet up and running in under 2 minutes:\n\n> **Prerequisites:** You must have QuantConnect credentials (User ID and API Token) before running the server. The server will not function without proper authentication. See [Authentication](#-authentication) section for details on obtaining these credentials.\n\n### **Install with uvx (Recommended)**\n```bash\n# Install and run directly from PyPI - no cloning required!\nuvx quantconnect-mcp\n\n# Or install with uv/pip\nuv pip install quantconnect-mcp\npip install quantconnect-mcp\n```\n\n\n### One-Click Claude Desktop Install (Recommended)\n\n1. **Download:** Grab the latest `quantconnect-mcp.dxt` from the \u201cReleases\u201d page\n2. **Install:** Double-click the file \u2013 Claude Desktop opens and prompts you to **Install**\n3. **Configure:** In Claude Desktop \u2192 **Settings \u2192 Extensions \u2192 QuantConnect MCP**, paste your user ID and API token\n4. **Use it:** Start a new Claude chat and call any QuantConnect tool\n\n\n**Why DXT?**\n> Desktop Extensions (`.dxt`) bundle the server, dependencies, and manifest so users go from download \u2192 working MCP in **one click** \u2013 no terminal, no JSON editing, no version conflicts.\n\n### 2. **Set Up QuantConnect Credentials (Required)**\n**The server requires these environment variables to function properly:**\n```bash\nexport QUANTCONNECT_USER_ID=\"your_user_id\"        # Required\nexport QUANTCONNECT_API_TOKEN=\"your_api_token\"    # Required\nexport QUANTCONNECT_ORGANIZATION_ID=\"your_org_id\" # Optional\n```\n\n### 3. **Launch the Server**\n```bash\n# STDIO transport (default) - Recommended for MCP clients\nuvx quantconnect-mcp\n\n# HTTP transport\nMCP_TRANSPORT=streamable-http MCP_PORT=8000 uvx quantconnect-mcp\n```\n\n### 4. **Interact with Natural Language**\n\nInstead of calling tools programmatically, you use natural language with a connected AI client (like Claude, a GPT, or any other MCP-compatible interface).\n\n> \"Initialize a research environment, add GOOGL, AMZN, and MSFT, then run a PCA analysis on them for 2023.\"\n\n\n## \u25c8 Authentication\n\n### Getting Your Credentials\n\n| Credential | Where to Find | Required |\n|------------|---------------|----------|\n| **User ID** | Email received when signing up | \u25c9 Yes |\n| **API Token** | [QuantConnect Settings](https://www.quantconnect.com/settings/) | \u25c9 Yes |\n| **Organization ID** | Organization URL: `/organization/{ID}` | \u25e6 Optional |\n\n### Configuration Methods\n\n#### Method 1: Environment Variables (Recommended)\n```bash\n# Add to your .bashrc, .zshrc, or .env file\nexport QUANTCONNECT_USER_ID=\"123456\"\nexport QUANTCONNECT_API_TOKEN=\"your_secure_token_here\"\nexport QUANTCONNECT_ORGANIZATION_ID=\"your_org_id\"  # Optional\n```\n\n<details open>\n<summary>Demo \u2013 Roo Code</summary>\n\n<div align=\"center\">\n  <video width=\"832\" src=\"https://github.com/user-attachments/assets/4d0e8074-aa27-4041-befc-b4119b5eaec6\"></video>\n</div>\n\n</details>\n\n## \u25c8 Natural Language Examples\n\nThis MCP server is designed to be used with natural language. Below are examples of how you can instruct an AI assistant to perform complex financial analysis tasks.\n\n### Factor\u2011Driven Portfolio Construction Pipeline\n\n> **\u201cBuild a global equity long/short portfolio for 2025:**\n> 1. Pull the **constituents of QQQ, SPY, and EEM** as of **2024\u201112\u201131** (survivor\u2011bias free).\n> 2. For each symbol, calculate **Fama\u2011French 5\u2011factor** and **quality\u2011minus\u2011junk** loadings using daily data **2022\u201101\u201101\u202f\u2192\u202f2024\u201112\u201131**.\n> 3. Rank stocks into terciles on **value (B/M)** and **momentum (12\u20111)**; go long top tercile, short bottom, beta\u2011neutral to the S&P 500.\n> 4. Within each book, apply **Hierarchical Risk Parity (HRP)** for position sizing, capped at **5\u202f% gross exposure per leg**.\n> 5. Target **annualised ex\u2011ante volatility \u2264\u202f10\u202f%**; solve with **CVaR minimisation** under a 95\u202f% confidence level.\n> 6. Benchmark against **MSCI World**; report **annualised return, vol, Sharpe, Sortino, max DD, hit\u2011rate, turnover** for the period **2023\u201101\u201101\u202f\u2192\u202f2024\u201112\u201131**.\n> 7. Export the optimal weights and full tear\u2011sheet as `pdf` + `csv`.\n> 8. Schedule a monthly rebalance job and push signals to the live trading endpoint.\u201d\n\n---\n\n### Robust Statistical\u2011Arbitrage Workflow\n\n> **\u201cTest and refine a pairs\u2011trading idea:**\n> \u2022 Universe: **US Staples sector, market cap\u202f>\u202f$5\u202fB, price\u202f>\u202f$10**.\n> \u2022 Data: **15\u2011minute bars, 2023\u201101\u201102\u202f\u2192\u202f2025\u201106\u201130**.\n> \u2022 Step 1\u00a0\u2013\u00a0For all pairs, calculate **rolling 60\u2011day distance correlation**; keep pairs with dCor\u202f\u2265\u202f0.80.\n> \u2022 Step 2\u00a0\u2013\u00a0Run **Johansen cointegration** (lag\u202f=\u202f2) on the survivors; retain pairs with trace\u2011stat\u202f<\u202f5\u202f% critical value.\n> \u2022 Step 3\u00a0\u2013\u00a0For each cointegrated pair:\n> \u00a0\u00a0\u00a0\u2013\u00a0Estimate **half\u2011life of mean\u2011reversion**; discard if >\u202f7\u202fdays.\n> \u00a0\u00a0\u00a0\u2013\u00a0Compute **Hurst exponent**; require H\u00a0<\u00a00.4.\n> \u2022 Step 4\u00a0\u2013\u00a0Simulate a **Bayesian Kalman\u2011filter spread** to allow time\u2011varying hedge ratios.\n> \u2022 Entry: z\u2011score crosses \u00b12 (two\u2011bar confirmation); Exit: z\u202f=\u202f0 or t_max\u202f=\u202f3\u202f\u00d7\u202fhalf\u2011life.\n> \u2022 Risk: cap **pair notional at 3\u202f% NAV**, portfolio **gross leverage \u2264\u202f3\u202f\u00d7**, stop\u2011loss at z\u202f=\u202f4.\n> \u2022 Output: trade log, PnL attribution, **bootstrapped p\u2011value of alpha**, and **Likelihood\u2011Ratio test** for regime shifts.\u201d\n\n\n### Automated Project, Backtest & Hyper\u2011Parameter Sweep\n\n> **\u201cSpin up an experiment suite in QuantConnect:**\n> 1. Create project **\u2018DynamicPairs_Kalman\u2019** (Python).\n> 2. Add files:\n> \u00a0\u00a0\u00a0\u2022 `alpha.py`\u00a0\u2013\u00a0signal generation (placeholder)\n> \u00a0\u00a0\u00a0\u2022 `risk.py`\u00a0\u2013\u00a0custom position sizing\n> \u00a0\u00a0\u00a0\u2022 `config.yaml`\u00a0\u2013\u00a0parameter grid:\n> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0```yaml\n> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0entry_z:  [1.5, 2.0, 2.5]\n> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0lookback: [30, 60, 90]\n> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hedge:    ['OLS', 'Kalman']\n> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0```\n> 3. Trigger a **parameter\u2011sweep backtest** labelled **\u2018GridSearch\u2011v1\u2019** using **in\u2011sample 2022\u201123**.\n> 4. When jobs finish, rank runs by **Information Ratio** and **max DD <\u202f10\u202f%**; persist **top\u20113 configs**.\n> 5. Automatically launch **out\u2011of\u2011sample backtests 2024\u2011YTD** for the winners.\n> 6. Produce an executive summary: tables + charts (equity curve, rolling Sharpe, exposure histogram).\n> 7. Package the best model as a **Docker image**, push to registry, and deploy to the **live\u2011trading cluster** with a kill\u2011switch if **1\u2011day loss\u202f>\u202f3\u202f\u03c3**.\u201d\n\n### Statistical Analysis Workflow\n\n> \"Are Coca-Cola (KO) and Pepsi (PEP) cointegrated? Run the test for the period from 2023 to 2024. If they are, analyze their mean-reversion properties with a 20-day lookback.\"\n\n### Project and Backtest Management\n\n> \"I need to manage my QuantConnect projects. First, create a new Python project named 'My_Awesome_Strategy'. Then, create a file inside it called 'main.py' and add this code: `...your algorithm code here...`. After that, compile it and run a backtest named 'Initial Run'. When it's done, show me the performance results.\"\n\n## \u25c8 Comprehensive API Reference\n\n### \u25c6 Authentication Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `configure_quantconnect_auth` | Set up API credentials | `user_id`, `api_token`, `organization_id` |\n| `validate_quantconnect_auth` | Test credential validity | - |\n| `get_auth_status` | Check authentication status | - |\n| `test_quantconnect_api` | Test API connectivity | `endpoint`, `method` |\n| `clear_quantconnect_auth` | Clear stored credentials | - |\n\n### \u25c6 Project Management Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `create_project` | Create new QuantConnect project | `name`, `language`, `organization_id` |\n| `read_project` | Get project details or list all | `project_id` (optional) |\n| `update_project` | Update project name/description | `project_id`, `name`, `description` |\n| `compile_project` | Compile a project for backtesting | `project_id` |\n\n### \u25c6 File Management Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `create_file` | Create file in project | `project_id`, `name`, `content` |\n| `read_file` | Read file(s) from project | `project_id`, `name` (optional) |\n| `update_file_content` | Update file content | `project_id`, `name`, `content` |\n| `update_file_name` | Rename file in project | `project_id`, `old_file_name`, `new_name` |\n\n### \u25c6 QuantBook Research Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `initialize_quantbook` | Create new research instance | `instance_name`, `organization_id`, `token` |\n| `list_quantbook_instances` | View all active instances | - |\n| `get_quantbook_info` | Get instance details | `instance_name` |\n| `remove_quantbook_instance` | Clean up instance | `instance_name` |\n\n### \u25c6 Data Retrieval Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `add_equity` | Add single equity security | `ticker`, `resolution`, `instance_name` |\n| `add_multiple_equities` | Add multiple securities | `tickers`, `resolution`, `instance_name` |\n| `get_history` | Get historical price data | `symbols`, `start_date`, `end_date`, `resolution` |\n| `add_alternative_data` | Subscribe to alt data | `data_type`, `symbol`, `instance_name` |\n| `get_alternative_data_history` | Get alt data history | `data_type`, `symbols`, `start_date`, `end_date` |\n\n### \u25c6 Statistical Analysis Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `perform_pca_analysis` | Principal Component Analysis | `symbols`, `start_date`, `end_date`, `n_components` |\n| `test_cointegration` | Engle-Granger cointegration test | `symbol1`, `symbol2`, `start_date`, `end_date` |\n| `analyze_mean_reversion` | Mean reversion analysis | `symbols`, `start_date`, `end_date`, `lookback_period` |\n| `calculate_correlation_matrix` | Asset correlation analysis | `symbols`, `start_date`, `end_date` |\n\n### \u25c6 Portfolio Optimization Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `sparse_optimization` | **Advanced sparse optimization** | `portfolio_symbols`, `benchmark_symbol`, optimization params |\n| `calculate_portfolio_performance` | Performance metrics | `symbols`, `weights`, `start_date`, `end_date` |\n| `optimize_equal_weight_portfolio` | Equal-weight optimization | `symbols`, `start_date`, `end_date`, `rebalance_frequency` |\n\n### \u25c6 Universe Selection Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `get_etf_constituents` | Get ETF holdings | `etf_ticker`, `date`, `instance_name` |\n| `add_etf_universe_securities` | Add all ETF constituents | `etf_ticker`, `date`, `resolution` |\n| `select_uncorrelated_assets` | Find uncorrelated assets | `symbols`, `num_assets`, `method` |\n| `screen_assets_by_criteria` | Multi-criteria screening | `symbols`, `min_return`, `max_volatility`, etc. |\n\n### \u25c6 Backtest Management Tools\n\n| Tool | Description | Key Parameters |\n|------|-------------|----------------|\n| `create_backtest` | Create new backtest from compile | `project_id`, `compile_id`, `backtest_name` |\n| `read_backtest` | Get backtest results | `project_id`, `backtest_id`, `chart` |\n| `read_backtest_chart` | Get chart data | `project_id`, `backtest_id`, `name` |\n| `read_backtest_orders` | Get order history | `project_id`, `backtest_id`, `start`, `end` |\n| `read_backtest_insights` | Get insights data | `project_id`, `backtest_id`, `start`, `end` |\n\n## \u25c8 Architecture\n\n```\nquantconnect-mcp/\n\u251c\u2500\u2500 \u25c6  quantconnect_mcp/          # Main package directory\n\u2502   \u251c\u2500\u2500 main.py                   # Server entry point & configuration\n\u2502   \u2514\u2500\u2500 src/                      # Source code modules\n\u2502       \u251c\u2500\u2500 \u2699  server.py          # FastMCP server core\n\u2502       \u251c\u2500\u2500 \u2699  tools/             # Tool implementations\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  auth_tools.py      # Authentication management\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  project_tools.py   # Project CRUD operations\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  file_tools.py      # File management\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  quantbook_tools.py # Research environment\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  data_tools.py      # Data retrieval\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  analysis_tools.py  # Statistical analysis\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  portfolio_tools.py # Portfolio optimization\n\u2502       \u2502   \u251c\u2500\u2500 \u25aa  universe_tools.py  # Universe selection\n\u2502       \u2502   \u2514\u2500\u2500 \u25aa  backtest_tools.py  # Backtest management\n\u2502       \u251c\u2500\u2500 \u25c6  auth/              # Authentication system\n\u2502       \u2502   \u251c\u2500\u2500 __init__.py\n\u2502       \u2502   \u2514\u2500\u2500 quantconnect_auth.py   # Secure API authentication\n\u2502       \u2514\u2500\u2500 \u25c6  resources/         # System resources\n\u2502           \u251c\u2500\u2500 __init__.py\n\u2502           \u2514\u2500\u2500 system_resources.py   # Server monitoring\n\u251c\u2500\u2500 \u25c6  tests/                     # Comprehensive test suite\n\u2502   \u251c\u2500\u2500 test_auth.py\n\u2502   \u251c\u2500\u2500 test_server.py\n\u2502   \u2514\u2500\u2500 __init__.py\n\u251c\u2500\u2500 \u25c6  pyproject.toml             # Project configuration\n\u2514\u2500\u2500 \u25c6  README.md                  # This file\n```\n\n### Core Design Principles\n\n- **\u25ce Modular Architecture**: Each tool category is cleanly separated for maintainability\n- **\u25aa Security First**: SHA-256 authenticated API with secure credential management\n- **\u26a1 Async Performance**: Non-blocking operations for maximum throughput\n- **\u25c6 Type Safety**: Full type annotations with mypy verification\n- **\u2699 Extensible**: Plugin-based architecture for easy feature additions\n\n## \u25c8 Advanced Configuration\n\n### Environment Variables\n\n| Variable | Description | Default | Example |\n|----------|-------------|---------|---------|\n| `MCP_TRANSPORT` | Transport method | `stdio` | `streamable-http` |\n| `MCP_HOST` | Server host | `127.0.0.1` | `0.0.0.0` |\n| `MCP_PORT` | Server port | `8000` | `3000` |\n| `MCP_PATH` | HTTP endpoint path | `/mcp` | `/api/v1/mcp` |\n| `LOG_LEVEL` | Logging verbosity | `INFO` | `DEBUG` |\n\n### System Resources\n\nYou can monitor server performance and status using natural language queries for system resources:\n\n> \"Show me the server's system info.\"\n\n> \"What's the current server status and are there any active QuantBook instances?\"\n\n> \"Give me a summary of all available tools.\"\n\n> \"Get the latest performance metrics for the server.\"\n\n> \"What are the top 10 most resource-intensive processes running on the server?\"\n\n## \u25c8 Testing\n\n### Run the Test Suite\n\n```bash\n# Run all tests\npytest tests/ -v\n\n# Run with coverage\npytest tests/ --cov=src --cov-report=html\n\n# Run specific test category\npytest tests/test_auth.py -v\n\n# Run tests in parallel\npytest tests/ -n auto\n```\n\n\n## \u25c8 Contributing\n\nWe welcome contributions! This project follows the highest Python development standards:\n\n### Development Setup\n\n```bash\n# Fork and clone the repository\ngit clone https://github.com/your-username/quantconnect-mcp\ncd quantconnect-mcp\n\n# Install development dependencies\nuv sync --dev\n\n# Install pre-commit hooks\npre-commit install\n```\n\n### Code Quality Standards\n\n- \u25c9 **Type Hints**: All functions must have complete type annotations\n- \u25c9 **Documentation**: Comprehensive docstrings for all public functions\n- \u25c9 **Testing**: Minimum 90% test coverage required\n- \u25c9 **Formatting**: Black code formatting enforced\n- \u25c9 **Linting**: Ruff linting with zero warnings\n- \u25c9 **Type Checking**: mypy verification required\n\n### Development Workflow\n\n```bash\n# Create feature branch\ngit checkout -b feature/amazing-new-feature\n\n# Make changes and run quality checks\nruff check src/\nblack src/ tests/\nmypy src/\n\n# Run tests\npytest tests/ --cov=src\n\n# Commit with conventional commits\ngit commit -m \"feat: add amazing new feature\"\n\n# Push and create pull request\ngit push origin feature/amazing-new-feature\n```\n\n### Pull Request Guidelines\n\n1. **\u25c6 Clear Description**: Explain what and why, not just how\n2. **\u25c6 Test Coverage**: Include tests for all new functionality\n3. **\u25c6 Documentation**: Update README and docstrings as needed\n4. **\u25c6 Code Review**: Address all review feedback\n5. **\u25c6 CI Passing**: All automated checks must pass\n\n## \u25c8 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n<div align=\"center\">\n\n**Built with precision for the algorithmic trading community**\n\n[![Python](https://img.shields.io/badge/Python-3.12%2B-blue.svg)](https://python.org)\n[![FastMCP](https://img.shields.io/badge/FastMCP-v2.7%2B-green.svg)](https://github.com/fastmcp/fastmcp)\n[![QuantConnect](https://img.shields.io/badge/QuantConnect-API%20v2-orange.svg)](https://www.quantconnect.com)\n\n[\u25c9 Star this repo](https://github.com/your-org/quantconnect-mcp) \u2022\n[\u25c9 Report issues](https://github.com/your-org/quantconnect-mcp/issues) \u2022\n[\u25c9 Request features](https://github.com/your-org/quantconnect-mcp/discussions)\n\n</div>\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Add your description here",
    "version": "0.1.11",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "38c51e21ff7967d484927fa1726e092b346dd415db2c88d67ea56ed18ead70f2",
                "md5": "3fef2f9cc59c0d9ad117d47563e6bd22",
                "sha256": "defcee3689b75425a32fdea5219830016a6776afa0214453a3b437950619824b"
            },
            "downloads": -1,
            "filename": "quantconnect_mcp-0.1.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3fef2f9cc59c0d9ad117d47563e6bd22",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 43598,
            "upload_time": "2025-07-22T22:38:17",
            "upload_time_iso_8601": "2025-07-22T22:38:17.945012Z",
            "url": "https://files.pythonhosted.org/packages/38/c5/1e21ff7967d484927fa1726e092b346dd415db2c88d67ea56ed18ead70f2/quantconnect_mcp-0.1.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "40cab5e41680c94bad43c72c6eb2c9becd94fd65c2da3855fb2d5602dfe2c749",
                "md5": "6480a55d841b09def8e5ea99e2184c5d",
                "sha256": "e16fc61858f0fed9de0d52d3dc5a2f4f03650fbb7e8758a475c862bcb29206e3"
            },
            "downloads": -1,
            "filename": "quantconnect_mcp-0.1.11.tar.gz",
            "has_sig": false,
            "md5_digest": "6480a55d841b09def8e5ea99e2184c5d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 44266,
            "upload_time": "2025-07-22T22:38:19",
            "upload_time_iso_8601": "2025-07-22T22:38:19.053536Z",
            "url": "https://files.pythonhosted.org/packages/40/ca/b5e41680c94bad43c72c6eb2c9becd94fd65c2da3855fb2d5602dfe2c749/quantconnect_mcp-0.1.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-22 22:38:19",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "quantconnect-mcp"
}
        
Elapsed time: 2.15351s