FullStack Alpha logo BestAITradingTools.com by FullStack Alpha
Red and green candlestick chart recovering after a pullback on a dark background

Backtesting deep dive

PyBroker Review | The Free Backtester That Makes Your ML Model Prove Itself

PyBroker logoPyBrokeredtechre/pybroker

PyBroker is a free Python framework for testing stock strategies on history, built around machine learning models and walk-forward analysis so your model is graded on data it never saw. It fits Python users who want honest numbers before trusting a model. The catch: it is a research lab, not a trading bot, and it is stocks only with no order-queue simulation.

Think of it as a driving test for your trading model: it trains on one stretch of road, then makes the model drive a stretch it has never seen, and grades it on that.

Listen · 1:35 audio briefing · voice: EricPyBroker Review | The Backtester That Makes Your AI Model Prove It
Read the transcript

What if your trading model had to pass a driving test before it got the keys? That's PyBroker. Here's why quants on Reddit like it.

PyBroker is a free Python library from developer Edward West for testing stock strategies, especially ones powered by machine learning. Think of a driving test: it trains your model on one stretch of road, then grades it on a stretch it's never seen.

Five things we like.

One, walk-forward testing. Train, test on fresh data, slide forward, repeat.

Two, bootstrapping, which reshuffles your results to show a range of outcomes, not one lucky number.

Three, it's fast, built on NumPy and Numba.

Four, version two added automatic tuning with Optuna, plus slippage modeling.

Five, data from Alpaca, Yahoo Finance and AKShare out of the box.

Threads on r/algotrading and Hacker News call it fast, free and well documented, with a responsive maintainer.

Two cautions. It's stocks only, and it tests strategies, it doesn't place trades. And the license includes a Commons Clause, so you can't sell a product built mainly on it.

Best for Python users who want honest numbers before trusting a model. Scroll down for the scorecard and setup steps.

This is education, not financial advice. Your market edge starts with the right tool. Stay alpha.

FullStack Alpha Editorial Team

Reviewed by Jay Rocco, Chief Editor

What Is PyBroker and What Does It Actually Do?

GitHub page for PyBroker (edtechre/pybroker)
edtechre/pybroker on GitHub · 2026

This is a Python library from developer Edward West for building and testing trading strategies, especially ones powered by machine learning (software that learns patterns from past data). You install it with one pip command, pull price data, write rules and models, and run a backtest (replaying your strategy on old prices to see what would have happened).

Its signature move is walk-forward analysis. Most beginner backtests train a model on all your history, then test it on that same history, which is like grading a student on the exact questions they studied. The library splits time into windows: train on one, test on the next, slide forward, repeat. The result looks far more like what live trading would have felt like.

It also uses bootstrapping, which resamples your trade results many times to show a range of outcomes rather than one lucky number. The engine runs on NumPy and Numba, which in plain terms means it sorts through big piles of numbers fast. It caches downloaded data, indicators and trained models so repeat runs do not start from scratch, and version 2 added Optuna for automatic parameter tuning.

Data comes from Alpaca, Yahoo Finance and AKShare out of the box, or any custom source you wire in. The docs do not describe live order placement, so treat it as the lab where ideas earn their way into a separate execution setup. It even ships skills that help AI coding agents write strategies and backtests for you.

Community Score

80 / 100

How we score
Adoption · How many people starred it
21.4 / 30
Maintenance · How recently the code was updated
25 / 25
Community sentiment · What traders say on Reddit and Hacker News
20 / 20
Builder activity · How many people built their own copy
9.3 / 15
License clarity · Whether you are clearly allowed to use it
4 / 10

GitHub data checked 2026. Community read: positive.

Stars
3,665
Forks (people who built on it)
460
Written in
Python
License
Other
Last update
2026-10-29
Markets
Stocks
Skill level
Intermediate

Works with

Any AI, through your own code
View edtechre/pybroker on GitHub ↗

Is PyBroker Right for You?

Good fit if you are

  • Python users building machine learning stock strategies who want testing that punishes overfitting
  • Systematic traders who care more about honest statistics than pretty equity curves
  • Students and self-taught quants who want a well-documented, free starting point
  • Anyone using an AI coding assistant to draft strategies and wanting a sound test harness

Skip it if you are

  • You want a bot that places trades for you. The docs describe testing, not live execution.
  • You trade options, perpetual futures or need order-book level simulation
  • You plan to sell a hosted product built mainly on it. The Commons Clause license forbids that.

The jargon, in plain English

Backtest
Replaying your strategy on old prices to see what would have happened.
Walk-forward analysis
Train on one slice of history, test on the next slice the model has never seen, then slide forward and repeat.
Overfitting
When a strategy memorizes the past instead of learning something that will hold up in the future.
Bootstrapping
Reshuffling your trade results many times to see the range of outcomes, not just one lucky number.
Vectorized
Processing whole columns of numbers at once, which is fast but skips some real-world order details.
Optuna
A free tool that automatically tries many settings to find the ones that test best.
Commons Clause
An add-on to an open-source license that lets you use the code freely but forbids selling it as a product or service.

What Do Traders Say About PyBroker?

This repo earns the warmest reception in this batch. Threads on r/algotrading, r/Python and Hacker News praise it as fast, free and well documented, and users single out walk-forward testing and bootstrapped metrics as the features that matter. Several people mention a responsive maintainer, and the version 2 release added Optuna tuning and slippage modeling.

The criticisms are specific and fair. It covers stocks only, with no options or perpetual futures. Because it processes data in bulk, it does not simulate an order queue, so fills in thin markets look cleaner than reality. And default data sources are limited to free feeds, which brings their own gaps.

“nice one, always good to see more open source backtesters out there”
golden_womanhood, r/algotrading, 2026

What they like

  • Fast, free and well documented
  • Walk-forward and bootstrapped metrics built in
  • Responsive maintainer, v2 adds Optuna and slippage

What they complain about

  • Stocks only, no options or perps
  • No order-queue simulation
  • Default data limited to free feeds

How Do You Set Up PyBroker Safely?

Plain steps, fake money first. Keep your keys in a private settings file, never pasted into the code.
  1. 01Install Python 3.11 or newerIt requires Python 3.11 or later and runs on Windows, Mac and Linux.
  2. 02Install the libraryRun pip install -U lib-pybroker. Note the package name starts with lib-, not just pybroker.
  3. 03Store data keys in an environment fileIf you use Alpaca for data, keep the API key and secret in a .env file or environment variables and load them in code, never typed into a shared notebook.
  4. 04Start with Yahoo Finance dataPull free daily data for a few large stocks and run a simple rule-based backtest from the docs to learn the workflow.
  5. 05Add a model and walk-forward testRegister a model with its training function, then run walk-forward analysis so every result comes from data the model never trained on.
  6. 06Paper trade any survivor elsewhereThe library does not place trades. Move a strategy that passes into a broker's paper account for a few months before any real money.

What Do You Need to Run PyBroker?

  • A computer with Python 3.11 or newer

    It is a Python library you run in scripts or Jupyter notebooks.

  • Historical price data

    Backtests need clean history. Free sources work for daily stock data.

  • Basic Python and pandas skills

    Rules, indicators and models are all written in code.

  • A separate broker for live trading

    The library tests ideas. Execution needs a broker account with its own paper mode.

What Are the Risks of Using PyBroker?

  • No live trading

    The docs describe backtesting and walk-forward analysis only. You will need separate code or tools to execute trades.

  • Cleaner fills than reality

    Bulk processing means no order-queue simulation. Thinly traded stocks will look easier to buy and sell than they really are.

  • Free data has holes

    Free feeds can carry missing bars, bad splits and survivorship bias (dead companies quietly missing from the list). Garbage in, flattering backtest out.

  • License limits commercial use

    Apache 2.0 with the Commons Clause means you cannot sell a product or service whose value comes mainly from the library. Personal and internal use is fine.

  • ML is easy to fool

    Walk-forward helps, but test enough ideas and one will look brilliant by luck. Keep a final untouched period for the last check.

Not ready to run code yourself? Our hands-on AI stock tool reviews on AIStockPickerApp.com score finished products on five pillars, the AI stock tools directory at AIStockPickerApps.com sorts 200+ tools by the job they do, and AIStockTradingBots.com walks through broker APIs, bot setup and backtesting step by step. Or head back to the Trading Workflows home page to match tools to your own routine and budget.

What Are the Best PyBroker Alternatives?

Should You Use PyBroker? Our Verdict

PyBroker does one job and does it honestly: it makes machine learning strategies pass a test that resembles real life. Walk-forward analysis, bootstrapped stats and fast processing are exactly the guardrails most retail quants skip, and the community response is the most positive in this group. For a free tool, that is real value.

Know its lane. It will not place trades, it will not model options, and its fills are kinder than the real market. Use PyBroker as the filter that kills bad ideas cheaply, then paper trade the survivors at a real broker. Systems beat hacks, and this is a system for saying no.

Here is the practical test. If your idea cannot survive walk-forward testing on free daily data, it will not survive slippage, fees and your own nerves in a live account. Run that test first, write down the result, and only then spend money on better data or a live setup.

Community Score

80

out of 100 · method

More PyBroker Questions, Answered

What is PyBroker?

PyBroker is a free Python framework for backtesting trading strategies, with a focus on machine learning. Its standout features are walk-forward analysis, bootstrapped performance metrics and a fast NumPy and Numba engine.

Is PyBroker free?

Yes, for personal and internal use. It is licensed under Apache 2.0 with the Commons Clause, which forbids selling a product or service whose value comes mainly from PyBroker.

Does PyBroker support live trading?

Its docs describe backtesting and walk-forward testing, not live order placement. Most users pair it with a broker's own API for execution after a strategy passes testing.

What data sources does PyBroker use?

Alpaca, Yahoo Finance and AKShare are built in, and you can plug in any custom data source. The examples focus on US stocks.

Is PyBroker good for machine learning trading?

Yes, that is its core purpose. You register models and training functions, and walk-forward analysis trains and tests them on rolling windows so results reflect unseen data.

Sources we checked

Incoming transmission | Free weekly newsletter

Stop paying for tools that don't earn their seat.

FullStack Alpha has tested 200 AI stock tools. Be honest: how many of yours do the same job, and which one did you forget you signed up for?

One email a week fixes that: which tools are worth the money, what they cost right now, and how the traders on this site wire them into a routine. Five minutes to read. Zero noise.

Free. One email a week. Unsubscribe in one click. We never sell your email.

  • Hot stock picks
  • Paid signal pitches
  • Fake countdown timers
  • Gurus selling courses

Inside every issue

5 MIN READ

  1. 01

    The Verdict

    One AI trading tool tested and scored. What it does well, what it costs, and the catch the sales page leaves out.

  2. 02

    Price Watch

    Price changes and live promos on the tools traders actually use, monthly and annual side by side, so you stop overpaying.

  3. 03

    Workflow Teardown

    One educator's routine taken apart: the scan, the chart, the tools, and the free swap for every paid one.

  4. 04

    Scan of the Week

    Exact scanner settings you can copy, pulled from the educator's own lesson with the timestamp.

Process beats prediction. This is the email that keeps your process honest.

FullStack Alpha logo

FullStack Alpha Network