quant2repo

License: Apache 2.0 Python 3.9+ GitHub Actions Documentation Finance

Educational agentic framework for converting quantitative finance research into backtesting repositories

quant2repo is an open source educational tool designed to help students and researchers understand how to convert quantitative finance research papers into production-ready backtesting repositories. It demonstrates domain-specific applications of Agentic Collective Intelligence (ACI) systems in financial contexts, serving as a specialized engine within the any2repo-gateway ecosystem.

📚 Table of Contents

Educational Purpose

This tool serves educational purposes by helping students and researchers:

Key Features

Advanced Features

Domain-Specific Validation

Financial-specific validation including:

Strategy Catalog

Built-in catalog of systematic trading strategies covering:

Financial Data Integration

Integration with financial data sources:

Quant-Specific Metrics

Financial performance metrics:

Framework Comparison

Comparison with Quantitative Finance Platforms

Feature Quant2Repo QuantConnect Quantopian Backtrader Zipline
Research Paper Input ✅ Native PDF parsing ❌ No ❌ No ❌ No ❌ No
Strategy Extraction ✅ LLM-powered ❌ Manual ❌ Manual ❌ Manual ❌ Manual
Bias Detection ✅ Auto detection ❌ No ⚠️ Limited ❌ No ❌ No
ACI Architecture ✅ Multi-agent DAG ❌ Single model ❌ Single model ❌ No ❌ No
Multi-Cloud Support ✅ Token economics ❌ No ❌ No ❌ No ❌ No
Strategy Catalog ✅ 47 pre-indexed ⚠️ Community ⚠️ Community ❌ No ❌ No
Backtest Validation ✅ Auto verification ✅ Yes ✅ Yes ✅ Yes ✅ Yes
Financial Metrics ✅ Comprehensive ✅ Yes ✅ Yes ✅ Yes ✅ Yes
Data Persistence ✅ Iceberg/DuckDB ⚠️ Cloud DB ⚠️ Cloud DB ❌ No ❌ No
Educational Focus ✅ Learning-oriented ⚠️ Mixed ⚠️ Mixed ❌ Production ❌ Production

Comparison with AI Trading Tools

Feature Quant2Repo TradeIdeas TrendSpider Kavout EquBot
Research-to-Code ✅ Core focus ❌ No ❌ No ❌ No ❌ No
Paper-Aware ✅ Academic context ❌ No ❌ No ❌ No ❌ No
Strategy Extraction ✅ LLM-powered ❌ Manual ❌ Manual ❌ Manual ❌ Manual
Bias Detection ✅ Auto detection ❌ No ❌ No ❌ No ❌ No
Explainable AI ✅ Transparent ❌ No ❌ No ❌ No ❌ No
Open Source ✅ Apache 2.0 ❌ Proprietary ❌ Proprietary ❌ Proprietary ❌ Proprietary
Custom Strategies ✅ Any paper ❌ Pre-built ❌ Pre-built ❌ Pre-built ❌ Pre-built
Multi-Asset ✅ 6 asset classes ⚠️ Limited ⚠️ Limited ⚠️ Limited ⚠️ Limited
Backtesting ✅ Full pipeline ✅ Yes ✅ Yes ✅ Yes ✅ Yes
Academic Rigor ✅ Paper-based ❌ No ❌ No ❌ No ❌ No

Comparison with General Research2Repo

Feature Quant2Repo Research2Repo Difference
Domain Focus ✅ Quantitative Finance ✅ General CS Specialized vs General
Strategy Extraction ✅ Financial signals ✅ General algorithms Domain-specific logic
Bias Detection ✅ Financial biases ❌ N/A Quant-specific validation
Strategy Catalog ✅ 47 strategies ❌ N/A Pre-indexed strategies
Financial Metrics ✅ Sharpe, drawdown, etc. ❌ N/A Domain-specific metrics
Data Sources ✅ yfinance, FRED ❌ N/A Financial data APIs
Asset Classes ✅ 6 classes ❌ N/A Equities, crypto, etc.
Backtest Focus ✅ Core feature ⚠️ Optional Specialized pipeline
ACI Architecture ✅ Multi-agent DAG ✅ Multi-agent DAG Shared foundation
Gateway Integration ✅ any2repo-gateway ✅ any2repo-gateway Same orchestration

Unique Differentiators

1. Financial Research Specialization

2. Bias Detection Engine

3. Strategy Catalog System

4. Financial Metrics Suite

5. Multi-Asset Class Support

6. Financial Data Integration

7. ACI for Finance

8. Academic Rigor

9. Educational Quant Finance

10. Gateway Integration for Scale

Quick Start

Installation

# Clone the repository
git clone https://github.com/nellaivijay/quant2repo.git
cd quant2repo

# Install dependencies
pip install -r requirements.txt

Provider Setup

# Google Gemini (recommended)
export GEMINI_API_KEY="your_key_here"

# OpenAI GPT-4o
export OPENAI_API_KEY="your_key_here"
pip install openai

# Anthropic Claude
export ANTHROPIC_API_KEY="your_key_here"
pip install anthropic

# Ollama (local models)
ollama pull deepseek-coder-v2

Basic Usage

# From research paper URL
python main.py --pdf_url "https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1079975"

# From local PDF file
python main.py --pdf_path ./papers/momentum.pdf

# Agent mode with decomposed planning
python main.py --pdf_url "..." --mode agent

# Agent mode with self-refine loops
python main.py --pdf_url "..." --mode agent --refine

# Agent mode with execution sandbox
python main.py --pdf_url "..." --mode agent --execute

# From strategy catalog
python main.py --catalog time-series-momentum

# List all strategies
python main.py --list-catalog

Architecture

Classic Mode

PDF → [Paper Parser] → [Strategy Extractor] → [Planner] → [Coder] → [Validator] → Repository

Agent Mode

PDF → [Paper Parser] → [Strategy Extractor] → [Decomposed Planner] → [Per-File Analyzer]
  → [CodeRAG] → [Context-Managed Coder] → [Test Generator] → [Code Validator]
  → [Backtest Validator] → [Execution Sandbox] → [Auto-Debugger] → [DevOps Generator]
  → [Reference Evaluator] → Repository

Pipeline Stages

  1. PaperParser: Multi-backend PDF parsing for financial papers
  2. StrategyExtractor: Extract signals, portfolio rules, equations, parameters
  3. DecomposedPlanner: 4-stage planning (overall → architecture → signal logic → config)
  4. FileAnalyzer: Per-file deep analysis with accumulated context
  5. CodeRAG: Mine GitHub for reference backtest implementations
  6. CodeSynthesizer: File-by-file code generation with context management
  7. TestGenerator: Auto-generated pytest suite for backtesting
  8. CodeValidator: Self-review and iterative auto-fix
  9. BacktestValidator: Bias detection and validation
  10. ExecutionSandbox: Run backtest in sandbox environment
  11. AutoDebugger: Iterative error fixing
  12. DevOpsGenerator: Generate Dockerfile, Makefile, CI
  13. ReferenceEvaluator: Score against paper-reported results

Strategy Catalog

Built-in catalog covering multiple asset classes:

Project Structure

quant2repo/
├── main.py                    # CLI entry point
├── config.py                  # Global configuration
├── providers/                 # Multi-model abstraction
├── core/                      # Pipeline stages
│   ├── paper_parser.py
│   ├── strategy_extractor.py
│   ├── planner.py
│   ├── file_analyzer.py
│   ├── coder.py
│   └── validator.py
├── quant/                     # Quant-specific modules
│   ├── catalog.py
│   ├── signals.py
│   ├── asset_classes.py
│   ├── metrics.py
│   └── data_sources.py
├── advanced/                  # Advanced capabilities
│   ├── backtest_validator.py
│   ├── cache.py
│   ├── executor.py
│   ├── debugger.py
│   ├── evaluator.py
│   ├── devops.py
│   ├── test_generator.py
│   ├── code_rag.py
│   └── context_manager.py
├── agents/                    # Multi-agent orchestration
├── prompts/                   # Quant-specific prompts
├── catalog/                   # Strategy catalog data
└── tests/                     # Test suite

Development

Adding New Strategies

Add new strategies to the strategy catalog following existing patterns.

Testing

Run the test suite:

pytest tests/

Performance Metrics

Quant2Repo has been evaluated on 47 systematic trading strategies across multiple asset classes:

Strategy Catalog Coverage

Bias Detection Performance

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/nellaivijay/quant2repo.git
cd quant2repo

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run tests
pytest tests/

# Run linting
black .
flake8 .
mypy .

Adding New Strategies

To add a new trading strategy to the catalog:

  1. Create a new entry in catalog/strategies.json
  2. Add strategy metadata (asset class, signals, rules, parameters)
  3. Include reference paper DOI and implementation notes
  4. Add test cases for the strategy
  5. Update documentation

Citation

If you use Quant2Repo in your research, please cite:

@article{quant2repo2024,
  title={Quant2Repo: Agentic Collective Intelligence for Converting Quantitative Finance Research into Backtesting Repositories},
  author={Nella, Vijay},
  journal={arXiv preprint arXiv:2024.xxxxx},
  year={2024},
  url={https://arxiv.org/abs/2024.xxxxx}
}

Acknowledgments

Quant2Repo is part of the ACI (Agentic Collective Intelligence) ecosystem:

License

Apache 2.0 License - See LICENSE file for details.

Educational Use

This tool is provided for educational purposes to help students and researchers learn about: