Guides · Updated 2026-11-09 · Backtest and paper results only, not financial advice.
How to Backtest a Trading Bot (Free, in Python): A Checklist From 5 Viral Bots
To backtest a trading bot for free, write its rules as code, run them over years of historical prices, and score the result against simply buying and holding the same asset. Python, pandas and free Yahoo Finance data are enough. The hard part isn't the code, it's honesty: compute signals on the close and fill on the next bar, charge slippage, test a long window that includes crashes, and test on the bar size you'll actually trade. Below is the checklist we use on viral AI trading bots, with the numbers each step changed. All results are backtests or paper trades, not financial advice.
What you need (all free)
- Rules a computer can follow. “Buy when the 20-day average crosses above the 50-day” is testable. “Buy strong stocks” isn't.
- Price data. The yfinance library pulls free daily bars from Yahoo Finance, including adjusted prices that account for dividends and splits. Intraday history is much shorter.
- A simulator. A plain pandas loop works, or an open-source library such as backtesting.py. Ours is a small Python engine that every number on this site comes from.
- A benchmark. Buy-and-hold of the same market. Without it, any positive number looks good.
The 7-step backtest checklist
1. Start with fixed money and a long window
We start every bot with $10,000 on 2019-01-02, about 7 years ago. That window includes the 2020 crash and the 2022 bear market, so a bot can't look good just by riding one bull run. Holding SPY over it returned +240.5% with a worst drop of -33.7%; holding Bitcoin returned +1795.6% with a worst drop of -76.6%.
2. Signal on the close, fill on the next bar
This one rule removes the most common bug, look-ahead bias. If your code sees today's close and buys at today's close, it's trading on information it didn't have. We compute signals on the daily close and fill at the next day's open. When we had ChatGPT write backtests for 5 viral bots with this rule spelled out, none of the scripts had a look-ahead bug.
3. Charge for trading
We charge 5 basis points (0.05%) of slippage per fill on ETFs and 10 on crypto, and zero commission. That sounds tiny, but it adds up for busy bots: the viral multi-asset bot we tested made 234 trades on daily bars and 812 on 1-hour bars over just two years.
4. Compare with buy-and-hold
This is the step that changes the story most. Only 1 of the 5 viral AI bots we backtested beat holding their own market:
| Viral bot we tested | Backtest return | Worst drop | Win rate | Buy-and-hold, same market |
|---|---|---|---|---|
| Multi-asset (stocks, Bitcoin, gold) | +369.8% | -13.8% | 36.3% of 234 | SPY +240.5% |
| Dip-ladder crypto | +242.8% | -44.0% | 100.0% of 309 | BTC-USD +1795.6% |
| HMM regime switcher | +90.7% | -11.0% | 66.7% of 66 | SPY +240.5% |
| 20/50 moving-average crossover | +84.9% | -28.2% | 58.8% of 17 | SPY +240.5% |
| BTC mean reversion | +83.0% | -47.9% | 72.7% of 44 | BTC-USD +1795.6% |
Hypothetical backtests from 2019-01-02, data as of 2026-11-09. Full rankings on the leaderboard. Not advice.
5. Report the worst drop, not just the win rate
Win rate is the easiest number to fake by accident. A viral dip-ladder crypto bot we tested won 100% of its 309 trades and still fell 44.0% from its peak, because it never sells at a loss; it just holds. A BTC mean-reversion bot won 72.7% of its trades with a -47.9% drawdown. Always print maximum drawdown and trade count next to the return.
6. Test on the bar size you'll trade
The one bot that beat its benchmark, the multi-asset bot, did it on daily bars: +369.8% vs SPY's +240.5%. Its creator traded 15-minute and 1-hour bars. On those, since 2026-07-27, it returned -3.4% while SPY made +2.3%. On 1-hour bars on every sleeve since 2024-10-28, it returned -22.9% vs +33.1% for SPY. Same rules, different data, opposite story (full results).
7. Write down every assumption, then rerun it a second way
Vague rules produce different backtests. When ChatGPT backtested the same 5 bots, 1 matched our numbers fully and 4 were partial. It read “split equity into slots” in the dip-ladder bot as fixed $1,000 slots and got +141.4% where we got +266.2%. The HMM regime bot came out at +105.3% vs our +83.8%, from fitting details the prompt left open, and the multi-asset bot at +320.9% vs +370.7%. List sizing, data source, adjusted vs raw prices, fill timing and costs before you trust a number. The exact prompts we used are free on the prompts page.
Backtesting with ChatGPT or Claude
AI chatbots are good at writing backtest code quickly, as long as you tell them the rules above. Put the fill rule, slippage, start date, start cash and benchmark in the prompt, ask for a trade log and an equity curve, and ask it to run the script end to end. Then check the result against a second source. One script ChatGPT wrote for a viral 20/50 crossover bot matched our 17 trades exactly but crashed on its last line from a missing import. More in can ChatGPT or Claude build a trading bot?
Red flags in your own results
- Very few trades. The 20/50 crossover bot had only 17 trades in 7 years. That's a handful of coin flips (every trade, broken down).
- A smooth curve with a tiny drawdown but low return. The HMM bot kept its worst drop to -11.0%, yet returned +90.7% vs +240.5% for SPY. Safe isn't the same as good.
- You tried many versions and kept the best. Test hundreds of settings and one will look great by luck. Retest the winner on data it never saw.
- It only works on one timeframe or one asset. See step 6.
For more warning signs, see the 10 red flags in AI trading bot claims.
After the backtest: paper trade
A backtest tells you what would have happened. Paper trading tells you whether your code actually trades the strategy live. We've paper-traded these bots since 2026-10-16, and we found that several ChatGPT-written paper modes didn't follow the backtest at all. Our paper trading guide covers the setup, and the broker AI tracker lists which brokers offer paper modes.
The bottom line
A free, honest backtest is a weekend project: next-bar fills, slippage, a long window, drawdown, and a buy-and-hold benchmark on the bar size you trade. Most viral bots we tested look worse once you add those, which is exactly why you should. Backtests are hypothetical and none of this is financial advice.
FAQ
How do I backtest a trading bot for free?
Write the rules as code in Python with pandas, pull free daily prices with yfinance, and simulate trades bar by bar: compute signals on the close, fill at the next bar's open, charge slippage, and compare the result with buying and holding the same asset. Open-source libraries like backtesting.py or Backtrader can do the bookkeeping for you.
Can ChatGPT backtest a trading strategy?
It can write and run backtest code. We gave ChatGPT the rules of 5 viral bots: 1 passed and 4 were partial. Two matched our engine exactly; the others drifted because the prompts left details open, such as position sizing. Always check its numbers against a second backtest.
What is look-ahead bias in a backtest?
It's when the backtest uses information it couldn't have had at the time, such as trading at today's close on a signal computed from today's close. The fix is to compute the signal on one bar and fill on the next bar's open.
How many years should a backtest cover?
Long enough to include a crash and a recovery. Ours start on 2019-01-02, which covers the 2020 crash and the 2022 bear market. A backtest with only a handful of trades, like the 17 trades of a viral 20/50 crossover bot we tested, is still thin evidence.
Does a good backtest mean the bot will make money?
No. A backtest is hypothetical. Of 5 viral AI bots we backtested, 1 beat buy-and-hold, and even that one lost money on hourly bars. Paper trade before risking real money. None of this is financial advice.
Get the weekly receipts. Subscribe free and get the Bot Builder Starter Kit (14-page PDF): 5 tested prompts, a hype-detector checklist, and safe paper-trading rules.
Form not showing? Subscribe on beehiiv
Related guides
- Do AI Trading Bots Actually Work? What 5 Viral Bots Did in Backtests
- Can ChatGPT or Claude Build a Trading Bot? We Graded 5 Prompts
- Which Brokers Let AI Trade for You? Robinhood, Alpaca, IBKR and 12 More
- Is That AI Trading Bot Legit? 10 Red Flags to Check First
- How to Paper Trade an AI Trading Bot: Brokers, Setup and Pitfalls
- Can ChatGPT Trade Stocks for You? What It Can and Can't Do
- Do Crypto AI Trading Bots Work? 2 Viral Bots vs Holding Bitcoin
- Moving Average Crossover Backtest: A Viral 20/50 SPY Bot Since 2019
- HMM Regime Switching Strategy: A Viral Bull/Bear Bot Backtested Since 2019
- How Much Do AI Trading Bots Cost? Prices of 54 Tools Compared