PyBroker is a Python framework for developing algorithmic trading strategies that leverage machine learning.
The framework addresses the challenge of building, testing, and optimizing trading strategies by combining backtesting capabilities with machine learning integration. It provides a backtesting engine built on NumPy and accelerated with Numba for performance, allowing developers to define trading rules and models that execute across multiple instruments. The tool supports walkforward analysis to simulate realistic strategy performance during actual trading, and includes bootstrapping-based metrics for more reliable performance evaluation. Developers can access historical data from multiple sources including Alpaca, Yahoo Finance, and AKShare, or integrate custom data providers. Parameter optimization through Optuna helps identify the best strategy parameters, while caching and parallelized computation speed up the development workflow.
PyBroker suits developers and quantitative traders who want to incorporate machine learning into their trading strategies rather than relying solely on rule-based approaches. It works well for those backtesting strategies across stocks and cryptocurrencies who need both rapid iteration and statistically sound performance metrics. The framework is particularly valuable for traders who want to experiment with multiple time intervals simultaneously, from daily to monthly signals, and who benefit from automated parameter tuning.
The project shows consistent development activity with regular updates to its codebase. The maintainers actively expand the framework's capabilities, as evidenced by ongoing additions to core functionality. Documentation is comprehensive and maintained alongside the code, with detailed notebooks covering key workflows from basic setup through advanced techniques like parameter optimization and parallelization. The project includes integration with external tools like Optuna for hyperparameter tuning and supports emerging use cases such as AI agent skills for strategy generation.