Skip to main content

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.

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)
$ 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

(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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pwb_alphaevolve-0.1.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pwb_alphaevolve-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

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

Hashes for pwb_alphaevolve-0.1.0.tar.gz
Algorithm Hash digest
SHA256 886a158034816667acc3b51b2ff3ab6543e70b5d7eda8f4323e00954b5ac43b7
MD5 d51e1b67872b95eb7af03f0ec3137207
BLAKE2b-256 ec1c831c438383da8c17474d1b5cbf9ccf87bafab563e3e189696fa214844375

See more details on using hashes here.

File details

Details for the file pwb_alphaevolve-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pwb_alphaevolve-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 619c1faab65ac065c9cddc998a9f601cd34ed1a550e37d76d9a666436e99b064
MD5 b0cdeb3fbfa29ccfa29f20fd9e39af0c
BLAKE2b-256 a9ba92deee77627828bd676c9d5e0e436db9a1d1ac8a64790bcfb4eb130da3f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page