Can ChatGPT or Claude backtest a trading strategy?

Yes, if it runs code on real bars. In our Bitcoin test, leaving out fees showed 464.36% where the rule made 167.73%. Four mistakes and a checklist.

Yes, an AI can backtest a trading strategy when it can run code and has real price bars to run it on. But it can get the answer badly wrong. In our hourly Bitcoin test, leaving out fees would have shown a gain of 464.36% where the same rule really gained 167.73%, and one timing slip turned a losing rule into a fake winner. These are past cases, not a forecast.

A backtest runs a trading rule on old prices to see what it would have done. The AI can do the typing. You still need to check the work.

For that timing slip step by step, see Look-ahead bias backtest example.

What can an AI do in a backtest?

With a tool that runs code, an AI app such as ChatGPT or Claude can do the whole routine:

  • Pull price bars. A bar is the open, high, low and close price over a set time.
  • Write the rule as code.
  • Run it, count the trades and report the result.
  • Change one setting and run it again, many times.

A chat window with no code tool can only describe these steps. The two things an AI cannot do for you are decide what is fair to test and notice a result that is too good. Those are the checks below.

Mistake 1: Does the rule use the future?

This slip is easy to make and hard to see. We tested a rule on Binance BTCUSDT (a Bitcoin perpetual future, or perp: a contract that follows the price and never expires). The honest version goes long or short for the next hour based on the last finished hour. The broken version used the hour it was about to trade.

Both used the same 61,901 hours from September 2019 to September 2026 and the same fees.

Mistake 1: Does the rule use the future?
Version Sharpe Average per hour after fees Hours with a gain
Honest -8.00 -0.06% 40.17%
Broken 59.41 +0.33% 87.21%

Sharpe compares average results with how much they swing. A score in the fifties does not mean a great strategy. It means a bug. We explain it in our look-ahead bias example.

Mistake 2: Does the test charge fees?

A fee is paid every time a position opens or closes. A rule that trades a lot pays a lot.

We tested a simple rule: hold Bitcoin while a 20-bar moving average is above a 50-bar one, and stay out otherwise. The table shows Binance BTCUSDT from September 2019 to October 2026. The rule makes the same number of trades whatever the fee. "Position changes" counts each time it moved in or out.

Mistake 2: Does the test charge fees?
Bar size Position changes per year Total before fees After 0.05% per side After 0.10% per side
1 hour 209.5 464.36% 167.73% 26.96%
4 hours 50.9 257.77% 198.53% 149.07%
1 day 8.0 590.71% 571.23% 552.30%

On hourly bars, fees took away nearly two thirds of the gain. At 0.05% per side, the hourly rule paid about 10.47% of its position in fees each year. On daily bars, fees barely mattered. The more often a rule trades, the more it pays. Our fee study has the same test for Ethereum and Solana.

A rule that flips between long and short pays twice for each flip. The same rule with shorting allowed lost 11.48% before fees on hourly bars and 80.09% after a 0.05% fee per side.

If you do not give the AI a fee, it may leave fees out. Always state the fee in your first message.

Mistake 3: Is the result better than doing nothing?

A result can look good just because the market went up. Over the same hourly stretch, simply holding Bitcoin gained 692.09%. The moving-average rule gained less, even before fees.

A second check is a random baseline. We placed the same number of random entries 200 times with the same holding times. In 23% of those random runs, the result after fees beat the rule.

So ask the AI for two comparisons: holding the coin, and random entries with the same number of trades.

Mistake 4: Was the rule picked after peeking?

If an AI tries 50 versions and shows you the best, the best may just be lucky. Hide a later stretch of dates before starting, choose the rule without looking, and test once. In our test of 1,000 random Bitcoin rules, the rule with the best score on 2019 to 2022 gained 155.22% after fees there, then lost 51.72% on 2023 to 2026. You can read it in our overfitting study.

Our fee tests also use only Bitcoin, Ethereum and Solana, which still trade today. Coins that disappeared are not in the data. Ask the AI which coins it left out.

What checklist should you give your AI before it starts?

Paste these rules into your first message:

  1. Use completed bars only. Decide at a bar's close and enter on the next bar.
  2. For every input, tell me when it was first known.
  3. Delete all prices after one decision time and recompute it. It must not change.
  4. Charge a fee on every side. A flip from long to short is two sides.
  5. Compare with holding the coin and with random entries.
  6. Keep a later stretch of dates hidden until the end, and test once.
  7. Report the number of trades, the worst fall and the date range.
  8. List what you left out: funding, spread, slippage, delays and dead coins.
Four steps before you trust an AI backtestIllustration of the order of checks, with numbers from the hourly Bitcoin moving-average test. Step 1, completed bars only. Step 2, a rule with a one-bar delay. Step 3, a 0.05% fee on every side: 464.36% before fees becomes 167.73% after. Step 4, compare with holding the coin (692.09%) and with random entries, which beat the rule in 23% of 200 runs.ILLUSTRATION / BACKTEST STEPSFour steps, in orderCheck these before you trust a result.1. Completed barsBTCUSDT 1-hour bars, Sep 2019 to Oct 20262. Rule with a one-bar delayA close sets the next bar's position.20 and 50 bar moving-average rule.3. Fee on every side0.05% per side. A flip is two sides.464.36% before fees, 167.73% after4. Compare with holding the coinand random entriesRule, after fees167.73%Hold the coin692.09%Random entries beat the rule after feesin 23% of 200 runs.Source: Binance BTCUSDT perpetual hourly bars,Comparand archive. Sep 2019 to Oct 2026.comparand.xyz
Four steps before you trust an AI backtest

What do these results not show?

We did not test ChatGPT or Claude. We tested fixed rules and showed how known mistakes change a result, and people make the same ones. For checks on the agent itself, such as stale data and spending caps, see 6 guardrails for AI trading agents. One moving-average rule on three large coins is not a search for something that works. Our fee test covers only a taker fee of 0.05% per side and leaves out funding payments, spread and slippage, so real costs are higher.

How we measured this

For the look-ahead test, we used Binance BTCUSDT hourly bars and a rule fixed in advance. The only difference between versions was whether the position came from the previous hour's return or the coming hour's.

For the fee test, the rule's reading at one bar's close set the position that earns the next bar's return. We ran the 20 and 50 bar moving-average rule on 1-hour, 4-hour and 1-day bars for BTC, ETH and SOL, and charged the fee on every change of position.

Try this in Comparand

Ask your connected AI agent: "Get completed 1-hour bars for Binance BTCUSDT from 2023-01-01 to 2024-01-01. Backtest a 20 and 50 bar moving-average rule with a 0.05% fee on each side. Tell me when each input was known."

  • venue_bars returns open, high, low, close and volume for completed bars, at 1 minute, 5 minute, 15 minute, 1 hour, 4 hour or 1 day. It is free on every key.
  • Your agent writes and runs the rule on those bars. The tool returns prices, not backtest results.

For Hyperliquid, ask: "Give me download links for the Hyperliquid archive files for these 30 days."

  • hl_bulk_link returns signed download links for whole archive files, for 1 to 100 days at a time. Each link lasts 24 hours and allows 5 downloads. Plans include 40, 200 or 800 GB of links per month (Starter, Pro, Desk). Pay-as-you-go is $0.15 per GB.

And: "For these 100 decision times, find the closest past Hyperliquid moments for BTC and show what happened over the next hour."

  • hl_analogs_batch runs up to 100 searches in one call. Each result has its own source record. It costs $0.01 per search that runs, and refused searches are not charged.
  • These compare a Hyperliquid coin with its own past and show what followed each one. There is no average and no hit rate.

See how to connect Claude or ChatGPT with MCP or the docs to connect your agent, or try 3 coins free.

The short version

  • An AI can backtest if it can run code on real price bars. It cannot judge whether the test is fair.
  • A timing bug moved a Bitcoin rule from a Sharpe of -8.00 to 59.41 on the same hours.
  • Fees cut a simple hourly Bitcoin rule from 464.36% to 167.73%, and trading often is what costs the most.
  • Compare with holding the coin and with random entries, and keep later dates hidden until the end.
  • Give your AI the checklist first. Past cases describe what happened, not what will.

Questions people ask

Can ChatGPT or Claude backtest a trading strategy?

Yes, when the AI app can run code and has real price bars to run it on. A chat with no code tool can only describe a backtest. Even with both, you must check the timing and fees, because a one-line timing bug moved our Bitcoin test from a Sharpe of -8.00 to 59.41.

What mistakes does an AI make when it backtests?

The four we show here are using information from the future, leaving out fees, not comparing with simply holding the coin, and picking the best of many tries without a test on unseen dates. People make the same mistakes, so the checks are the same for both.

How much do fees change a backtest?

A lot when a rule trades often. A simple moving-average rule on hourly Binance Bitcoin gained 464.36% before fees and 167.73% after a 0.05% fee on each side, from September 2019 to October 2026.

Where can an AI agent get crypto price data for a backtest?

It needs bars it can read. Comparand's venue_bars tool returns open, high, low, close and volume for completed bars on many exchanges, from 1 minute to 1 day, and it is free on every key.

Is a backtest from an AI proof a strategy will work?

No. A backtest describes what a rule would have done on past prices. It does not say what will happen next, and it leaves out costs such as funding, spread and slippage unless you add them.

Read next