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
Metadata
Release files for pwb-alphaevolve 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pwb_alphaevolve-0.1.0.tar.gz | 13.8 kB | Without provenance | Details for pwb_alphaevolve-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pwb_alphaevolve-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pwb_alphaevolve-0.1.0-py3-none-any.whl |
Total release size: 21.2 kB
Release files / pwb_alphaevolve-0.1.0.tar.gz
| Download URL | pwb_alphaevolve-0.1.0.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
886a158034816667acc3b51b2ff3ab6543e70b5d7eda8f4323e00954b5ac43b7
|
|
BLAKE2b-256 checksum How to use checksums |
ec1c831c438383da8c17474d1b5cbf9ccf87bafab563e3e189696fa214844375
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / pwb_alphaevolve-0.1.0-py3-none-any.whl
| Download URL | pwb_alphaevolve-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
619c1faab65ac065c9cddc998a9f601cd34ed1a550e37d76d9a666436e99b064
|
|
BLAKE2b-256 checksum How to use checksums |
a9ba92deee77627828bd676c9d5e0e436db9a1d1ac8a64790bcfb4eb130da3f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for pwb-alphaevolve 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.