Quant Autoresearch is an autonomous framework for quantitative strategy discovery. Based on the OPENDEV terminal-agent architecture, it treats alpha generation as a long-horizon code evolution problem.
Unlike traditional backtesters, this system deploys a compound AI ensemble that formulates hypotheses, analyzes academic literature (ArXiv), writes Python code, and validates performance in a secure, sandboxed environment.
Defines immutable behavioral constraints, risk limits (e.g., "Max Drawdown < 20%"), and the investment mandate. These rules are injected into every reasoning step.
Powered by bm25s for high-speed retrieval of quantitative finance papers. The agent decides when to "read" academic theory to ground its code generation in proven science rather than LLM hallucination.
A sandboxed validation layer implementing strict Defense-in-Depth Safety:
- Walk-Forward Validation: Prevents overfitting via rolling out-of-sample windows.
- Forced Signal Lag: Eliminates look-ahead bias by shifting signals by 1 bar.
- Volatility-Adjusted Slippage: Models realistic market impact during choppy regimes.
- RestrictedPython Sandboxing: Executes AI strategies in a hardened, non-virtualized sandbox. It strips all standard
importstatements and provides onlypdandnpin a safe global namespace, blocking access toos,sys, and other sensitive built-ins.
Ensures long-horizon autonomy by monitoring token pressure and automatically pruning or summarizing old observations to prevent context overflow.
├── cli.py # Main entry point (CLI)
├── src/
│ ├── core/ # Engine logic, research RAG, and backtester
│ ├── strategies/ # AI-evolved strategies (active_strategy.py)
│ ├── safety/ # 5-layer safety guardrails
│ ├── models/ # Multi-provider LLM routing (Groq, Moonshot)
│ ├── memory/ # SQLite-based pattern playbook
│ ├── tools/ # Tool registry and execution
│ └── prompts/ # System instructions & "The Constitution"
├── data/cache/ # Local Parquet market data files
└── experiments/ # Results, logs, and SQLite databases
Requires Python 3.10+ and the uv package manager.
# Clone the repository
git clone https://github.com/yllvar/quant-autoresearch.git
cd quant-autoresearch
# Install dependencies using uv
uv syncCreate a .env file with your API keys:
GROQ_API_KEY=your_key_here
MOONSHOT_API_KEY=your_key_here
WANDB_API_KEY=your_key_here
WANDB_PROJECT=quant-autoresearch# Fetch and index market data (SPY, QQQ, BTC, ETH)
python src/data/preprocessor.pyStart the autonomous discovery process:
# Run for 10 iterations with high safety
python cli.py run --iterations 10 --safety high --approval semipython cli.py status
python cli.py reportThis project uses a 5-Layer Defense-in-Depth system:
- Prompt Guardrails: Behavioral constraints in system prompts.
- Schema Gating: Dangerous tools are hidden from non-executor subagents.
- Runtime Approval: "Semi-Auto" mode for high-risk operations.
- Tool Validation: Argument sanitization before execution.
- Look-Ahead Scanner: AST-based code analysis to block
shift(-1)or future data leaks.
Integration with Weights & Biases (W&B) provides real-time telemetry of:
- Strategy Evolution (Sharpe Ratio improvement over time).
- Token Usage & API Cost.
- Agent Reasoning Traces and Tool Success Rates.
MIT License. Disclaimer: This software is for research purposes only. Do not deploy evolved strategies to live capital without exhaustive manual review.