- With Claude, we built a Python bot that trades BTC, ETH, SOL and BNB on Binance Testnet, risking 1% per trade.
- On two years of 4-hour data it made +6.67% over 207 trades while buy-and-hold lost 23%, but only 30% of trades won and most profit came from ETH.
- On about four years of daily candles: 77 trades, +10.79%, max drawdown -1.71%.
- The AI caught a subtle bug that could skip trading signals; backtests do not guarantee future results and this is not financial advice.
Can someone who is not a professional programmer build a working crypto trading bot just by describing it to an AI? We tried. Over a few chat sessions with Claude, Rachid Amesrouy built a Python bot that trades four cryptocurrencies on Binance, limits the loss on every trade, and runs on an ordinary Windows PC. Then we tested it on two years of real price data and connected it to Binance's Testnet, where it trades with play money. Here is what the AI built, what went wrong, and what the numbers really say.
What we asked for
The first question was simple: "Can you build a program that buys and sells automatically and enters trades with a small loss margin?" Before writing any code, the AI was blunt: no program can guarantee profits, a very tight stop-loss is not always better because normal price noise keeps hitting it, and most people who start automated trading lose money at first. It recommended starting with crypto on Binance Testnet, because the API is free and you can test with fake money, and avoiding leverage entirely.
What the AI built
- Language and libraries: Python, with
ccxtto talk to Binance,pandasfor price data andmatplotlibfor charts. API keys stay in a separate.envfile, never in the code. - Markets: BTC, ETH, SOL and BNB against USDT, each managed separately with an equal share of the capital.
- Strategy: a breakout strategy on 4-hour candles: buy when the price breaks above its recent highs, then follow it with a trailing stop that moves up as the price rises.
- Risk rules: each trade risks only 1% of capital, a stop-loss based on volatility (ATR), a daily loss limit after which the bot stops opening trades, and no leverage.
- Safety details: it ignores the candle that has not closed yet, never acts on an old signal at start-up, saves open positions to a file so it remembers them after a restart, and never tries to sell more than the account actually holds.
- Tools around it: a backtest script, and a report script that produces a summary, charts and a CSV of every trade.
The bug the AI found by itself
On the first live day, the bot printed three connection timeouts in 40 minutes. They were harmless (Testnet servers are slower than the real exchange), but reviewing the code because of them, the AI found a real flaw: if a timeout happened exactly when a 4-hour candle closed, the bot marked that candle as "processed" without finishing its checks. It could miss a buy signal, or fail to raise the stop on an open trade, and those candles come only six times a day.
The fix: a candle is now marked as processed only after every request succeeds; the bot waits up to 30 seconds instead of 10; and it asks for the balance only when a trade opens or closes. The AI then tested the fix on a simulated exchange that deliberately failed 30% of requests, and the bot kept running without missing trades. It also replaced long technical error messages with a clear note: "temporary connection loss, retrying in a minute, no need to worry".
Backtest results: two years on 4-hour candles
We ran the strategy on real Binance price history from November 30, 2024 to October 28, 2026, with $1,000 per coin ($4,000 total), 1% risk per trade and a 0.1% fee on every buy and sell.
| Result | Value |
|---|---|
| Number of trades | 207 |
| Winning trades | 30.4% |
| Net profit | +$266.88 (+6.67%) |
| Profit factor | 1.22 |
| Maximum drawdown | -9.26% |
| Buy and hold, same period | -23.10% |

The chart also shows something the summary hides: after peaking in October 2025, the bot slowly lost money for about ten months, drifting back to its starting $4,000, before a few big trades in August 2026 pushed it up again. Sitting through ten months of small losses is the hardest part of running a strategy like this.
By coin
| Coin | Trades | Winners | Bot return | Buy and hold | Max drawdown |
|---|---|---|---|---|---|
| BTC | 51 | 31.4% | +2.15% | -15.54% | -6.97% |
| ETH | 51 | 21.6% | +18.49% | -36.15% | -10.91% |
| SOL | 50 | 34.0% | +2.25% | -56.79% | -10.10% |
| BNB | 55 | 34.5% | +3.80% | +16.06% | -11.21% |

The pattern is typical of trend-following strategies: it loses most of the time (about 7 trades out of 10), but each loss is small (the worst was about -$13, close to the 1% risk limit), while a few big winners pay for everything. The best trade was ETH in August 2026: +28% in eleven days, +$148.
A second test: daily candles
Running the same strategy on daily candles over about four years (1,500 days) gave fewer but better trades: 77 trades, +$431.78 (+10.79%), a profit factor of 2.11 and a maximum drawdown of only -1.71%.
How to read these numbers honestly
- The good: the risk rules worked. The bot never lost more than about 1% per trade, and during a falling market it stayed positive while simply holding the coins lost 23%.
- The modest: +6.67% in almost two years is small, and a profit factor of 1.22 is thin. Slippage (getting a slightly worse price than expected) is not included and could eat much of it.
- The warning: most of the profit came from ETH. Without it, the bot barely beat its fees. And in a rising market (BNB), simply holding did much better.
- The trap: once you test several settings (4-hour, then daily), it is tempting to keep the one with the best past results. That is how backtests start to look better than reality. The daily result is encouraging, not proof.
The live test on Testnet
The bot runs on a Windows PC, connected to Binance Testnet with $10,000 of play money. Breakout signals on 4-hour candles are rare, and as of October 28, 2026 the account was still at $10,000 with no open trades. A trend-following bot can wait days or weeks for a setup, which is normal and a lesson in itself: these bots are slow and patient, not money machines. We will update this article with the live trades.
What we learned about building with AI
- A non-programmer can build a working bot with an AI assistant, including backtests, reports and error handling, but you still need to run it, read its logs and ask the right questions.
- The AI was most useful when it pushed back: warning about guarantees and leverage, insisting on fake money first, and catching a subtle bug nobody had noticed.
- Test before you trust: backtest, then paper trade on Testnet for weeks. Real money comes last, if ever, and only an amount you can afford to lose completely.
Related: Claude Code vs OpenAI Codex for building software with AI agents, and what Claude can do.