Skip to content

SL-Mar/quantcoder-cli

 
 

Repository files navigation

QuantCoder

License: MIT Python 3.9+ OpenAI

QuantCoder (CLI Version)

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.

✨ Key Features

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

πŸš€ Installation

Requirements

  • Python 3.9 or later
  • OpenAI API key

Setup

# 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" > .env

πŸ’‘ Usage

Interactive Mode

Launch the interactive CLI:

quantcli interactive

Or:

python -m quantcli.cli interactive

Command-Line Interface

Search for research articles:

quantcli search "momentum trading strategies" --num 5

List previously searched articles:

quantcli list

Download an article:

quantcli download 1

Process a PDF to generate algorithm:

quantcli process path/to/research-paper.pdf

πŸ“š Example Workflow

  1. Search for trading research:

    quantcli search "mean reversion high frequency" --num 3
  2. Download an interesting paper:

    quantcli download 1
  3. Generate QuantConnect algorithm:

    quantcli process downloads/paper.pdf
  4. Review generated code in generated_code/ directory

  5. Copy to QuantConnect and backtest

πŸ—οΈ Architecture

QuantCoder uses a dual-agent system:

  1. Extraction Agent: Analyzes PDF, identifies trading signals and risk management rules
  2. Generation Agent: Converts extracted information into QuantConnect Python code
  3. Validation Layer: Checks syntax and refines code using AST analysis

πŸ“Š What's New in v1.0.0

Major Improvements

βœ… 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.

πŸ§ͺ Testing

Run the test suite:

pytest

With coverage:

pytest --cov=quantcli --cov-report=html

πŸ“– Success Stories

  • βœ… 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)"

πŸ”§ Configuration

Create a .env file in the project root:

OPENAI_API_KEY=your-openai-api-key

Optional configuration:

# Change default model (default: gpt-4o-2024-11-20)
OPENAI_MODEL=gpt-4-turbo-preview

🀝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Contact

Author: SL-MAR Email: smr.laignel@gmail.com GitHub: @SL-Mar


⭐ If QuantCoder helps your trading research, give it a star! ⭐

About

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

Topics

Resources

License

Stars

Watchers

Forks