Logo vun QuantConnect

QuantConnect

Communautéit
taylorwilsdon

QuantConnect Algorithmic Trading Platform Orchestration MCP - Agentic LLM Driven Trading Strategy Design, Research & Implementation

Editeurtaylorwilsdon
Repositoryquantconnect-mcp
SproochPython
Forks
32
Stären
120
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    QuantConnect stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    120 Stären an 32 Forks aus dem verlinkte Repository.

◆ QuantConnect MCP Server

Python FastMCP License Code Style Type Checked PyPI Downloads

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 • ◉ Documentation • ◉ Architecture • ◉ Contributing


◈ Is this crazy?

  • 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.
  • Live Trading Management: Deploy, monitor, liquidate, and control live algorithms with comprehensive runtime statistics and logging.
  • Historical Data Access: Comprehensive data retrieval capabilities for historical and alternative data analysis.
  • 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

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 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).

"Add GOOGL, AMZN, and MSFT, then run a PCA analysis on them for 2023."

◈ Authentication

Getting Your Credentials

CredentialWhere to FindRequired
User IDEmail received when signing up◉ Yes
API TokenQuantConnect Settings◉ Yes
Organization IDOrganization 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

◈ 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."

Live Trading Deployment & Monitoring

"Deploy my compiled algorithm to live trading using Interactive Brokers paper trading. Set up the brokerage configuration with my IB credentials, then monitor the runtime statistics including equity, holdings, and net profit. If the algorithm shows a loss greater than 5%, automatically liquidate all positions and stop the algorithm."

Live Algorithm Management

"Show me all my currently running live algorithms. For each one, display the runtime statistics, recent logs from the last 100 lines, and current portfolio holdings. If any algorithm has been running for more than 24 hours without trades, flag it for review."

◈ Comprehensive API Reference

◆ Authentication Tools

ToolDescriptionKey Parameters
configure_quantconnect_authSet up API credentialsuser_id, api_token, organization_id
validate_quantconnect_authTest credential validity-
get_auth_statusCheck authentication status-
test_quantconnect_apiTest API connectivityendpoint, method
clear_quantconnect_authClear stored credentials-

◆ Project Management Tools

ToolDescriptionKey Parameters
create_projectCreate new QuantConnect projectname, language, organization_id
read_projectGet project details or list allproject_id (optional)
update_projectUpdate project name/descriptionproject_id, name, description
compile_projectCompile a project for backtestingproject_id
read_compilation_resultRead compilation job resultproject_id, compile_id

◆ File Management Tools

ToolDescriptionKey Parameters
create_fileCreate file in projectproject_id, name, content
read_fileRead file(s) from projectproject_id, name (optional)
update_file_contentUpdate file contentproject_id, name, content
update_file_nameRename file in projectproject_id, old_file_name, new_name

◆ Data Retrieval Tools

ToolDescriptionKey Parameters
add_equityAdd single equity securityticker, resolution, instance_name
add_multiple_equitiesAdd multiple securitiestickers, resolution, instance_name
get_historyGet historical price datasymbols, start_date, end_date, resolution
add_alternative_dataSubscribe to alt datadata_type, symbol, instance_name
get_alternative_data_historyGet alt data historydata_type, symbols, start_date, end_date

◆ Statistical Analysis Tools

ToolDescriptionKey Parameters
perform_pca_analysisPrincipal Component Analysissymbols, start_date, end_date, n_components
test_cointegrationEngle-Granger cointegration testsymbol1, symbol2, start_date, end_date
analyze_mean_reversionMean reversion analysissymbols, start_date, end_date, lookback_period
calculate_correlation_matrixAsset correlation analysissymbols, start_date, end_date

◆ Portfolio Optimization Tools

ToolDescriptionKey Parameters
sparse_optimizationAdvanced sparse optimizationportfolio_symbols, benchmark_symbol, optimization params
calculate_portfolio_performancePerformance metricssymbols, weights, start_date, end_date
optimize_equal_weight_portfolioEqual-weight optimizationsymbols, start_date, end_date, rebalance_frequency

◆ Universe Selection Tools

ToolDescriptionKey Parameters
get_etf_constituentsGet ETF holdingsetf_ticker, date, instance_name
add_etf_universe_securitiesAdd all ETF constituentsetf_ticker, date, resolution
select_uncorrelated_assetsFind uncorrelated assetssymbols, num_assets, method
screen_assets_by_criteriaMulti-criteria screeningsymbols, min_return, max_volatility, etc.

◆ Backtest Management Tools

ToolDescriptionKey Parameters
create_backtestCreate new backtest from compileproject_id, compile_id, backtest_name
read_backtestGet backtest resultsproject_id, backtest_id, chart
read_backtest_chartGet chart dataproject_id, backtest_id, name
read_backtest_ordersGet order historyproject_id, backtest_id, start, end
read_backtest_insightsGet insights dataproject_id, backtest_id, start, end

◆ Live Trading Management Tools

ToolDescriptionKey Parameters
create_live_algorithmDeploy live algorithm with brokerageproject_id, compile_id, node_id, brokerage_config
read_live_algorithmGet detailed runtime statistics & statusproject_id, deploy_id
liquidate_live_algorithmEmergency liquidation of all positionsproject_id
stop_live_algorithmStop live algorithm executionproject_id
list_live_algorithmsList algorithms with status filtersstatus, start, end
read_live_logsRead algorithm execution logsproject_id, algorithm_id, start_line, end_line

◈ 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
│       │   ├── ▪  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
│       │   └── ▪  live_tools.py      # Live trading 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

VariableDescriptionDefaultExample
MCP_TRANSPORTTransport methodstdiostreamable-http
MCP_HOSTServer host127.0.0.10.0.0.0
MCP_PORTServer port80003000
MCP_PATHHTTP endpoint path/mcp/api/v1/mcp
LOG_LEVELLogging verbosityINFODEBUG

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 file for details.


Built with precision for the algorithmic trading community

Python FastMCP QuantConnect

◉ Star this repo • ◉ Report issues • ◉ Request features

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "quantconnect-mcp": {
      "command": "uvx",
      "args": [
        "quantconnect-mcp"
      ],
      "env": {
        "QUANTCONNECT_USER_ID": "your_user_id",
        "QUANTCONNECT_API_TOKEN": "your_api_token",
        "QUANTCONNECT_ORGANIZATION_ID": "your_org_id"
      }
    }
  }
}

QuantConnect MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal QuantConnect verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

QuantConnect als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu QuantConnect an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "quantconnect": {
      "command": "npx",
      "args": [
        "-y",
        "quantconnect-mcp"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu QuantConnect. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu QuantConnect.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat QuantConnect?
QuantConnect
Jo. Ech hunn et gelies.
Dat hunn ech mat QuantConnect fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server QuantConnect benotzt?

QuantConnect ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech QuantConnect MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir QuantConnect mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat QuantConnect MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann QuantConnect verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech QuantConnect MCP mat TypingMind?

QuantConnect leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt QuantConnect MCP an TypingMind zur Verfügung?

QuantConnect stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir QuantConnect MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann QuantConnect eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇