Guides · Updated 2026-11-09 · Backtest and paper results only, not financial advice.
Can ChatGPT or Claude Build a Trading Bot? We Graded 5 Prompts
Yes, ChatGPT or Claude can write a trading bot that runs, but you shouldn't trust it until you've checked it. We gave the free version of ChatGPT (a GPT-5.x “Instant” model) 5 carefully written trading-bot prompts (each one a viral bot we tested) and compared every result with our own independent backtest engine. 1 passed outright. The other 4 ran cleanly with no look-ahead bug, but either got a different backtest result or shipped a “paper trading” mode that didn't trade the strategy. The AI is a strong coder. It just fills in every gap in your prompt with its own guess. These are backtest results, not advice.
What we tested
Each prompt asked for a Python 3.11 bot using pandas and free yfinance data, backtested from 2019 with $10,000, signals on the daily close and fills at the next day's open, slippage on every fill, a trade log, an equity curve, a buy-and-hold comparison, and an optional Alpaca paper trading mode. We ran the code ChatGPT gave us and graded it on 2026-10-16. The full prompts, free to copy, are on our prompts page.
| Viral bot we tested | Grade | ChatGPT's backtest | Our engine (at test time) |
|---|---|---|---|
| 20/50 moving-average crossover (SPY) | Partial | +92.1% / 16 trades | +92.1% / 16 trades |
| HMM regime switcher (SPY) | Partial | +105.3% / 67 trades | +83.8% / 64 trades |
| Multi-asset: stocks, Bitcoin, gold | Partial | +320.9% / 229 trades | +370.7% / 230 trades |
| Dip-ladder crypto (BTC + ETH) | Partial | +141.4% / 309 trades | +266.2% / 309 trades |
| BTC mean reversion | Pass | +83.0% / 44 trades | +83.0% / 44 trades |
Tested in ChatGPT Free (GPT-5.x "Instant" model; exact name not shown) on 2026-10-16, original prompt wording. Hypothetical backtests, not advice.
Where ChatGPT got it right
The simple bots came out clean. The BTC mean-reversion bot matched our numbers exactly: +83.0%, a -47.9% worst drop and 44 trades. The 20/50 crossover also matched to the trade. None of the five had a look-ahead bug, which is the classic mistake where a backtest “sees” tomorrow's price.
Where it went wrong
1. A crash on the last line
The 20/50 crossover script got the backtest exactly right, then crashed on its final line because it called json.dumps without importing json. The output files were still written. It's small, but it's a reminder to run the code before you trust it.
2. Reasonable guesses that changed the result
The dip-ladder bot got +141.4% where our engine got +266.2%. ChatGPT read “split equity into slots” as fixed $1,000 slots that never grow, while we resize slots to the current account. When we ran our engine with fixed slots, we got the same +141.4%. The logic matched. The prompt was ambiguous.
The multi-asset bot landed at +320.9% vs our +370.7%. We traced the gap to wording: ChatGPT computed Bitcoin breakout levels on US trading days only and used a slightly different Bollinger band setting. The HMM regime bot came out about 21 points above ours (+105.3% vs +83.8%), because hidden-Markov models are sensitive to the seed, how states get labeled, and how today's state is picked.
3. “Paper mode” that doesn't trade the strategy
This was the most common problem, and the most dangerous one. The BTC mean-reversion bot's paper mode only checked the Alpaca paper account and never placed an order. The dip-ladder paper mode only bought and never sold at its profit targets. The multi-asset paper mode dropped the stop-losses and used a fixed 10% position size. The HMM paper mode was a manual buy/sell helper. In every case the backtest looked fine, and the live-ish part quietly did something else.
How to prompt ChatGPT or Claude for a trading bot
- Write exact rules. “Buy when the 20-day average closes above the 50-day”, not “buy on a golden cross”. Say what happens on ties.
- Pin down timing. Signals on the close, fills at the next open. That one line prevents look-ahead bugs.
- Charge costs. We use 5 basis points of slippage per fill on ETFs and 10 on crypto.
- Name the sizing. Fixed dollars, percent of equity, or risk-based? Our dip-ladder gap came from this alone.
- Demand a benchmark. Buy-and-hold of the same asset over the same dates.
- Require paper mode to place the same orders as the backtest, with a
--dry-runflag, keys from environment variables, and only the paper endpoint. Alpaca's paper environment is the default and comes with Yes, default (ALPACA_PAPER_TRADE=true); $100k simulated; ChatGPT plugin is paper-only for orders money (Alpaca docs). - Ask it to confirm the script runs end to end with all imports present. Then run it yourself anyway.
- Check against an independent backtest. Our leaderboard has one for every bot we've tested. It also helps to plot a few of the bot's trades on a TradingView chart (affiliate link) and check each entry lands where the rules say it should.
We've since tightened all five prompts with these fixes. The new wording hasn't been retested yet, and the prompts page says so.
Should you let the AI trade for you?
Writing the code is one thing. Letting an AI agent place orders is another. Builders on Reddit put it bluntly: Claude is “amazing at coding and terrible at generating alpha” (r/algotrading). If you do connect an AI to a broker, start on paper and know what approval setting you're on. Some brokers make you approve every order and some don't. Our broker guide and broker AI tracker cover 15 of them, and the tools directory lists AI trading platforms if you'd rather not code at all.
FAQ
Can ChatGPT write a working trading bot?
Yes, with a precise prompt it can write a bot that runs, but you have to check it. We tested 5 trading-bot prompts in ChatGPT Free (GPT-5.x "Instant" model; exact name not shown) on 2026-10-16. 1 passed and 4 were partial: the code ran and had no look-ahead bug, but results drifted from our engine or the paper-trading mode didn't match the strategy. 2 of the 5 backtests matched ours exactly.
Is Claude or ChatGPT better for building a trading bot?
We have only graded ChatGPT so far, so we can't rank them yet. Our prompts are written to work in ChatGPT, Claude and Grok, and the same checks apply to any model: run the code, compare the backtest with an independent one, and confirm the paper mode places the same orders the backtest assumes.
Can ChatGPT trade stocks for me?
ChatGPT on its own can't place trades. It can connect to some brokers through MCP connectors, and whether those can place orders, and with what approval, depends on the broker. Our broker AI tracker compares 15 brokers.
What should a trading bot prompt include?
Exact entry and exit rules, how ties and edge cases are handled, the data source, when signals are computed and when orders fill (for example, signal on the close and fill at the next open), trading costs, starting cash, a benchmark, and a paper-only trading mode that reads keys from environment variables.
Why would ChatGPT's backtest differ from someone else's?
Usually because the prompt left a choice open. In our tests, ChatGPT used fixed-size position slots where we resized them, computed Bitcoin levels on stock-market days only, and picked different model-fitting details. Each choice was reasonable, but each one changed the result.
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
- 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
- How to Backtest a Trading Bot (Free, in Python): A Checklist From 5 Viral Bots
- 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