quantcoder

quantcoder

AI-powered CLI tool: Transform trading research papers into QuantConnect algorithms

Stars: 87

Visit
 screenshot

QuantCoder is a local-first CLI tool that generates QuantConnect trading algorithms from academic research papers. It uses local LLMs for code generation, refinement, and error fixing. The tool does not require cloud API keys and offers models for reasoning, summarization, and chat. Users can interact with QuantCoder through interactive, CLI, programmatic, and autonomous modes. It also features an evolution mode inspired by AlphaEvolve, backtesting with detailed metrics, library building, and integration with QuantConnect for backtesting and deployment. The tool's architecture includes components for CLI, configuration management, NLP, multi-agent system, evolution engine, self-improving pipeline, library builder, and integration with QuantConnect MCP.

README:

QuantCoder 2.0.0

Version Python License

Local-first CLI for generating QuantConnect trading algorithms from research papers — powered by Ollama

QuantCoder transforms academic quant research into compilable QuantConnect LEAN algorithms using local LLMs. No cloud API keys required.

Models (defaults):

  • qwen2.5-coder:14b — code generation, refinement, error fixing
  • mistral — reasoning, summarization, chat

Note: Testing with various local LLMs (devstral, qwen2.5-coder:32b, and others) is ongoing to determine optimal model pairings for the two-stage code generation pipeline. Any Ollama-compatible model can be configured via ~/.quantcoder/config.toml.


Installation

Prerequisites

  • Python 3.10+
  • Ollama running locally
# Pull the required models
ollama pull qwen2.5-coder:14b
ollama pull mistral

Setup

git clone https://github.com/SL-Mar/quantcoder-cli.git
cd quantcoder-cli

python -m venv .venv
source .venv/bin/activate

pip install -e .
python -m spacy download en_core_web_sm

Verify

# Check Ollama is running
curl http://localhost:11434/api/tags

# Launch QuantCoder
quantcoder

Usage

Interactive Mode

quantcoder        # or: qc

CLI Commands

# Search for papers
quantcoder search "momentum trading" --num 5

# Download and summarize
quantcoder download 1
quantcoder summarize 1

# Generate QuantConnect algorithm
quantcoder generate 1
quantcoder generate 1 --open-in-editor

# Validate and backtest (requires QC credentials)
quantcoder validate generated_code/algorithm_1.py
quantcoder backtest generated_code/algorithm_1.py --start 2022-01-01 --end 2024-01-01

Programmatic Mode

quantcoder --prompt "Find articles about mean reversion"

Autonomous Mode

quantcoder auto start --query "momentum trading" --max-iterations 50
quantcoder auto status

Evolution Mode (AlphaEvolve-inspired)

quantcoder evolve start 1 --gens 3 --variants 5
quantcoder evolve start 1 --gens 3 --push-to-qc   # Push best to QC
quantcoder evolve list
quantcoder evolve export abc123

Backtest with Detailed Metrics

# Shows Sharpe, Total Return, CAGR, Max Drawdown, Win Rate, Total Trades
quantcoder backtest generated_code/algorithm_1.py --start 2022-01-01 --end 2024-01-01

Library Builder

quantcoder library build --comprehensive --max-hours 24
quantcoder library status

Configuration

Configuration is stored in ~/.quantcoder/config.toml:

[model]
provider = "ollama"
model = "qwen2.5-coder:14b"
code_model = "qwen2.5-coder:14b"
reasoning_model = "mistral"
ollama_base_url = "http://localhost:11434"
ollama_timeout = 600
temperature = 0.5
max_tokens = 3000

[ui]
theme = "monokai"
editor = "zed"

QuantConnect Integration

For backtesting and deployment, set credentials in ~/.quantcoder/.env:

QUANTCONNECT_API_KEY=your_key
QUANTCONNECT_USER_ID=your_id

Remote Ollama

To use a remote Ollama instance:

[model]
ollama_base_url = "http://your-server:11434"

Architecture

quantcoder/
├── cli.py           # CLI entry point
├── config.py        # Configuration management
├── chat.py          # Interactive chat
├── llm/             # Ollama provider layer
├── core/            # LLM handler, processor, NLP
├── agents/          # Multi-agent system (Coordinator, Alpha, Risk, Universe)
├── evolver/         # AlphaEvolve-inspired evolution engine
├── autonomous/      # Self-improving pipeline
├── library/         # Batch strategy library builder
├── tools/           # Pluggable tool system
└── mcp/             # QuantConnect MCP integration

Background

QuantCoder was initiated in November 2023 based on "Dual Agent Chatbots and Expert Systems Design". The initial version coded a blended momentum/mean-reversion strategy from "Outperforming the Market (1000% in 10 years)", which received over 10,000 impressions on LinkedIn.

v2.0.0 is a complete rewrite — local-only inference, multi-agent architecture, evolution engine, and autonomous learning. Recent additions include a two-stage code generation pipeline (framework stubs then mathematical core), two-pass summarization for high-fidelity strategy extraction, and a cross-model fidelity assessment loop that prevents indicator substitution when papers describe novel mathematical models.


License

Apache License 2.0. See LICENSE.

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for quantcoder

Similar Open Source Tools

For similar tasks

For similar jobs