PyBroker is a Python framework for developing algorithmic trading strategies, with a particular focus on strategies that use machine learning. It pairs a very fast backtesting engine โ built on NumPy and accelerated with Numba โ with tools to train models, run walkforward analysis and evaluate strategies with bootstrapped metrics that resist overfitting. The project has around 3,600 stars on GitHub and remains actively maintained.
A PyBroker strategy combines data sources, indicators and execution rules or trained models, and can trade multiple instruments in one run. Historical data can come from Alpaca, Yahoo Finance or AKShare, or from a custom provider you plug in. Models are registered with a training function and retrained automatically inside walkforward windows, simulating how the strategy would actually have performed live. Downloaded data, indicators and models are cached to disk, and computations are parallelised, so iterating on a strategy is fast. The framework also handles practical details such as position sizing, ranking, stops, rebalancing and rotational trading, and ships an extensive user guide with notebooks for every feature.
PyBroker is free to use: install it from PyPI or clone the GitHub repository. Market-data subscriptions from providers such as Alpaca are separate and priced by those providers.
Quantitative traders, data scientists and Python developers who want to prototype and honestly evaluate machine-learning trading strategies for stocks and crypto before risking real capital.