Skip to content

paperswithbacktest/pwb-alphaevolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AlphaEvolve

Inspired by DeepMind’s AlphaEvolve coding agent—this project applies the same evolutionary-LLM principles to financial markets.

Autonomously discovers and back‑tests high‑performing algorithmic‑trading strategies using evolutionary LLM prompts, Backtrader, and the Papers‑With‑Backtest data ecosystem.

CI License


✨ Key Features

Layer Highlights
Data Zero‑setup loader for any Papers‑With‑Backtest dataset (pwb_toolbox) + caching to Feather
Strategies Seed templates with EVOLVE‑BLOCK markers that the LLM mutates
Evaluator Deterministic Backtrader walk‑forward, JSON KPIs (Sharpe, CAGR, Calmar, DD)
LLM Engine OpenAI o3 structured‑output chat → JSON diff/patch system
Evolution Async controller, SQLite hall‑of‑fame, optional MAP‑Elites niches
Dashboard (optional) Streamlit live view of metrics & equity curves

🚀 Quickstart

# Clone and install in editable mode $ git clone https://github.com/paperswithbacktest/pwb-alphaevolve.git $ cd pwb-alphaevolve $ pip install -e . # Set your OpenAI key (model "o3" required) $ export OPENAI_API_KEY=sk-... # Set your Papers‑With‑Backtest dataset (e.g. "paperswithbacktest/Stocks-Daily-Price") $ export HF_ACCESS_TOKEN=hf_

Launch the evolution controller (infinite loop)

from alphaevolve import AlphaEvolve # Initialize the system evolve = AlphaEvolve( initial_program_paths=["examples/sma_momentum.py"] ) # Run the evolution best_strategy = await evolve.run(iterations=1000) print(f"Best strategy metrics:") for name, value in best_strategy.metrics.items(): print(f" {name}: {value:.4f}")

Monitor the evolution process in real‑time using the optional Streamlit dashboard:

$ streamlit run scripts/dashboard.py

The dashboard uses Streamlit to visualize the evolution process and back‑test results.


📂 Project structure (high‑level)

alphaevolve/ ├── engine.py # convenience wrapper to run the evolution loop ├── evaluator/ # data loading, metrics & Backtrader evaluation ├── evolution/ # controller, patching, islands ├── llm_engine/ # prompt builder + OpenAI client ├── strategies/ # seed strategies (EVOLVE‑BLOCK markers) └── store/ # SQLite persistence scripts/ # CLI entry‑points 

⚙️ Installation

Python ≥ 3.10 required.

pip install pwb-alphaevolve

Or install the bleeding‑edge version:

pip install git+https://github.com/paperswithbacktest/pwb-alphaevolve.git

Core Dependencies

(See pyproject.toml for the full list.)


🤝 Contributing

  1. Fork the repo & create your feature branch (git checkout -b feat/new-feature).
  2. Commit your changes (git commit -m 'feat: add something').
  3. Push to the branch (git push origin feat/new-feature).
  4. Open a Pull Request.

Please run black + ruff before submitting.


📄 License

MIT © 2025 Contributors

About

DeepMind’s AlphaEvolve coding agent for trading strategies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages