Transform academic trading research into executable QuantConnect algorithms using AI.
QuantCoder is a command-line tool that converts research papers into production-ready QuantConnect trading algorithms using natural language processing and large language models. Based on a dual-agent cognitive architecture, it extracts trading signals, risk management rules, and generates tested Python code.
As of November 2025, it is under refactoring with readiness expected in February 2026.
- π PDF Processing: Extract trading strategies from academic papers
- π CrossRef Integration: Search and download financial research articles
- π€ AI-Powered Code Generation: Uses GPT-4o to generate QuantConnect algorithms
- β Syntax Validation: Automatic code validation and refinement
- π― Dual-Agent Architecture: Separates strategy extraction from code generation
- π Rich Terminal UI: Beautiful, interactive command-line interface
- Python 3.9 or later
- OpenAI API key
# Clone the repository
git clone https://github.com/SL-Mar/quantcoder-legacy.git
cd quantcoder-legacy
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install QuantCoder
pip install -e .
# Download required NLP model
python -m spacy download en_core_web_sm
# Set your OpenAI API key
echo "OPENAI_API_KEY=your-api-key-here" > .envLaunch the interactive CLI:
quantcli interactiveOr:
python -m quantcli.cli interactiveSearch for research articles:
quantcli search "momentum trading strategies" --num 5List previously searched articles:
quantcli listDownload an article:
quantcli download 1Process a PDF to generate algorithm:
quantcli process path/to/research-paper.pdf-
Search for trading research:
quantcli search "mean reversion high frequency" --num 3 -
Download an interesting paper:
quantcli download 1
-
Generate QuantConnect algorithm:
quantcli process downloads/paper.pdf
-
Review generated code in
generated_code/directory -
Copy to QuantConnect and backtest
QuantCoder uses a dual-agent system:
- Extraction Agent: Analyzes PDF, identifies trading signals and risk management rules
- Generation Agent: Converts extracted information into QuantConnect Python code
- Validation Layer: Checks syntax and refines code using AST analysis
β Migrated to OpenAI SDK 1.x+ - Modern API with better error handling β LLMClient abstraction layer - Easily swap LLM providers β Token usage tracking - Monitor API costs β Test infrastructure - pytest with coverage reporting β Improved logging - Structured logs for debugging β Type hints - Better code quality with mypy support
See CHANGELOG.md for full details.
Run the test suite:
pytestWith coverage:
pytest --cov=quantcli --cov-report=html- β 10K+ LinkedIn impressions on first algorithm generated
- β 79 GitHub stars from quantitative trading community
- β 21 forks actively used by traders worldwide
Original case study: "Outperforming the Market (1000% in 10 years)"
Create a .env file in the project root:
OPENAI_API_KEY=your-openai-api-keyOptional configuration:
# Change default model (default: gpt-4o-2024-11-20)
OPENAI_MODEL=gpt-4-turbo-previewContributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by "Dual Agent Chatbots and Expert Systems Design"
- Built for the QuantConnect algorithmic trading platform
- Powered by OpenAI GPT-4
Author: SL-MAR Email: smr.laignel@gmail.com GitHub: @SL-Mar
β If QuantCoder helps your trading research, give it a star! β