Autonomous evolution of algorithmic‑trading strategies using Backtrader, Papers With Backtest data, and OpenAI LLMs.
Project description
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.
✨ 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)
$ python scripts/run_controller.py
$ streamlit run scripts/dashboard.py
The dashboard uses Streamlit to visualize the evolution process and back‑test results.
📂 Project structure (high‑level)
alpha_trader/
├── data/ # loaders & helpers on top of pwb_toolbox
├── strategies/ # seed strategies (EVOLVE‑BLOCK markers)
├── evaluator/ # Backtrader KPIs & walk‑forward
├── llm_engine/ # prompt builder + OpenAI client
├── evolution/ # controller, patching, islands
└── 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/your‑org/pwb-alphaevolve.git
Core Dependencies
- pwb-toolbox
- pwb-backtrader
- backtrader ≥ 1.9
- openai ≥ 1.0 (structured output)
- tqdm, pandas, numpy, pydantic
(See pyproject.toml for the full list.)
🤝 Contributing
- Fork the repo & create your feature branch (
git checkout -b feat/new-feature). - Commit your changes (
git commit -m 'feat: add something'). - Push to the branch (
git push origin feat/new-feature). - Open a Pull Request.
Please run black + ruff before submitting.
📄 License
MIT © 2025 Contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pwb_alphaevolve-0.1.0.tar.gz.
File metadata
- Download URL: pwb_alphaevolve-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
886a158034816667acc3b51b2ff3ab6543e70b5d7eda8f4323e00954b5ac43b7
|
|
| MD5 |
d51e1b67872b95eb7af03f0ec3137207
|
|
| BLAKE2b-256 |
ec1c831c438383da8c17474d1b5cbf9ccf87bafab563e3e189696fa214844375
|
File details
Details for the file pwb_alphaevolve-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pwb_alphaevolve-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
619c1faab65ac065c9cddc998a9f601cd34ed1a550e37d76d9a666436e99b064
|
|
| MD5 |
b0cdeb3fbfa29ccfa29f20fd9e39af0c
|
|
| BLAKE2b-256 |
a9ba92deee77627828bd676c9d5e0e436db9a1d1ac8a64790bcfb4eb130da3f9
|