Guide

Mean Reversion Futures Bot with Claude: An Honest Test

We asked Claude for an RSI mean reversion bot on ETH futures and backtested it with real fees and funding. It won 64% of trades and still lost. Here is why.

Updated

You can build a mean reversion trading bot for crypto futures with Claude in a few minutes: describe the rule, let Claude write the code, and backtest it on real exchange data. We did exactly that with a classic RSI rule on ETHUSDT perpetual futures. The backtest was graded A for honesty, won 64% of its trades and lost 5.2%. This article walks through the build and explains why a losing result is the useful part.

The run was made on OptAlgo on 2026-11-22 with Binance data. It is one backtest, in-sample. Trading is risky, and nothing here is a recommendation to trade this or any strategy.

The idea in one sentence

Buy ETH when it is oversold inside an uptrend, and sell when it recovers.

That is mean reversion in its most common form. Price drops fast, RSI falls under 30, and the bet is that the drop was an overreaction that will partly reverse. The trend filter, price above the 200 EMA, is there to avoid buying dips in a market that is simply falling.

The prompt for Claude

Claude was connected to OptAlgo through the MCP connector. In Claude Code that is one command, then /mcp to sign in:

claude mcp add --transport http optalgo https://mcp.optalgo.com/mcp

In Claude.ai you add the same URL as a custom connector. The connector is paper-only: it can backtest and run paper bots and can never place a live order. Then the prompt, in plain words:

The last sentence matters. It sets the order in which results are read, and it stops the conversation from opening with a return figure.

The strategy logic

Claude writes a strategy.py with the OptAlgo SDK: vectorised Python with numpy, plain code you can read, download and keep. The core of this one is four lines:

rsi = indicators.rsi(c, 14)
trend = indicators.ema(c, 200)
go = (rsi < 30) & (c > trend)      # oversold inside an uptrend
out = rsi > 55                     # exit when it recovers

Everything is long-only and uses one position at a time. There is nothing clever in it, and that is the right place to start: a simple rule gives a result you can explain.

Free validation before the run

Before a backtest costs a unit, the agent validates. Validation is free. It runs the code once on synthetic bars and lists every problem at once: code errors, symbols, data for the window, plan limits and quota, plus lookahead and non-deterministic code. Each finding comes with its fix.

The lookahead part is worth a line. A mean reversion rule is easy to get wrong by one bar, for example by entering at the same close that produced the RSI reading. Validation checks that a decision at bar i does not change when the bars after it are removed. See lookahead bias for what that catches.

The result

ETHUSDT perpetual, 1h bars, 2023-01-01 to 2026-01-01, after fees and funding:

Read the grade first. Grade A means every fill settled on real data with fees, funding and exchange rules. So the loss is not a simulation artefact. These trades could have happened, and they would have lost money. The verdict for a losing run is no edge.

Why a 64% win rate lost money

Win rate counts how often you win. It says nothing about how much. Profit factor is the missing half: gross profit divided by gross loss. At 0.84, the strategy made 0.84 for every 1.00 it lost.

Do the arithmetic on 25 trades. A 64% win rate is 16 winners and 9 losers. For 16 winners to add up to less than 9 losers, the average loser has to be roughly twice the size of the average winner.

The rules explain why. The exit at RSI 55 takes profit early, as soon as the bounce is under way, so winners are small. The 4% stop lets a loser run a long way before it is cut, so losers are large. Many small wins and a few large losses is the standard shape of a mean reversion strategy, and it is why win rate is the most misleading number in this style.

The other number to notice is 25 trades in three years. That is a small sample. It is too few to say the idea is worthless, and far too few to tune.

What not to do next

The tempting move is to ask Claude: “try RSI 25 instead of 30, exit at 60, and a 3% stop”. Then again with other numbers. On 25 trades, some combination will turn the result positive. It will look like a fix and it will be a coincidence.

Each variant is another try on the same data, and the best of many tries looks good partly by luck. That is backtest overfitting. OptAlgo counts the variants you ran on overlapping data in the last 30 days and checks whether the Sharpe ratio survives that many tries, so tuning in a loop makes the verdict harder to pass, not easier.

A run with no edge is not something to tune. Change the idea instead.

What to do instead

  1. Change the idea, not the numbers. The weakness here is structural: small winners, large losers. A different exit, such as one tied to the size of the bounce, or a rule that skips entries during a sharp sell-off, is a new hypothesis. A new RSI threshold is not.
  2. Test on more coins. One coin and 25 trades is thin. Ask Claude to run the same rules on several coins together. On OptAlgo a basket splits capital equally and the grade is the worst symbol's, not the best. If the rule only works on one coin, you have learned something.
  3. Run one walk-forward research run. Instead of many single backtests, one research run optimises on a training window and judges the result on test windows the optimiser never saw. The verdict is robust, inconclusive or likely overfit. Inconclusive is not a pass.

How to read a research run is covered in walk-forward testing explained. The short version: the out-of-sample numbers are the ones that count.

Funding costs on perpetual futures

This test ran on a perpetual contract, so it carried a cost that spot trading does not have. A funding rate is a periodic payment between long and short holders that keeps the contract's price near spot, typically every 8 hours on Binance. When the rate is positive, longs pay shorts. When it is negative, shorts pay longs.

For a long-only strategy this means that holding a position while funding is positive costs money on top of fees. A mean reversion trade that waits days for a bounce can pay funding several times. The effect on one trade is small. Over a whole backtest it is part of the result, and a backtest that leaves it out is too optimistic for longs in a market where funding is mostly positive.

OptAlgo charges the exact historical funding payments in the backtest, which is one of the things grade A confirms. The -5.2% above already includes them.

Why we published a losing backtest

Most tutorials for a crypto mean reversion bot end with a rising equity curve. That teaches you to expect one, and to keep adjusting until you get it. The honest outcome of a first idea is usually this: it does not work, and you find out in ten minutes for a few backtest units instead of in a month with money.

That is the real use of Claude here. It makes testing an idea cheap enough that you can throw most of them away.

If a later version does hold up out of sample, the next step is paper, not live: a deployed strategy runs at every bar close as a paper bot in My Bots, and the deploy gate refuses a losing backtest like this one. To try the same test yourself, create a free account and read the Claude Code trading bot guide, or see how the AI strategy builder works.

Frequently asked questions

Can Claude build a mean reversion trading bot for crypto futures?

Claude can write and backtest the strategy code through the OptAlgo connector, and OptAlgo can run it as a paper bot. The connector is paper-only. Live trading happens only after you confirm it in the OptAlgo app, on a Plus or Pro plan.

Is RSI mean reversion profitable in crypto?

Not by default. In our test on the ETHUSDT perpetual, 1h bars from 2023 to 2026, a standard RSI rule with a trend filter lost 5.2% after fees and funding. That is one backtest on one coin, so it does not settle the question, but it shows the idea is not an edge on its own.

How can a strategy with a high win rate lose money?

When the average loss is larger than the average win. In our test 64% of trades won, but the profit factor was 0.84, which means losing trades were about twice the size of winning trades on average. Always read win rate together with profit factor.

Should I optimise RSI settings after a losing backtest?

Not by trying values one at a time on the same data. With few trades, some setting will look good by chance. Change the idea, test on more coins, or use one walk-forward run that judges the settings on data the optimiser never saw.

Do funding rates matter for a mean reversion bot on perpetuals?

Yes. A long position pays funding whenever the rate is positive, and a trade that waits days for a bounce can pay it several times. A backtest of a perpetual strategy should include the historical funding payments.

Your next strategy is one sentence away.
Test it honestly before it touches money.

Start free, no card

50 backtest units a month on the Free plan.