Guides · Updated · 7 min read

How to backtest a trading idea with Claude or ChatGPT

The short answer

A chatbot on its own can’t backtest: it has no price history and will make numbers up. Connect it to a tool that runs backtests on real data, and you can ask in plain words — “test a 50/200-day cross on SPY over 10 years” — and get the result next to buy and hold, year by year, with every trade and with costs included. With TradePuffin, Claude, ChatGPT or Gemini does this through its backtest tool, on one symbol or a whole watchlist.

Why you can’t just ask a chatbot

Without data, a model answers from memory: a plausible-sounding win rate, invented returns, no trades you can check. Even with a pasted CSV, it may do the arithmetic wrong. A backtest tool runs the rules on actual bars and returns figures you can audit.

A worked example: the 50/200-day cross on SPY

The “golden cross” — buy when the 50-day average crosses above the 200-day, sell when it crosses below — is often called a way to avoid crashes. We asked the agent to test it on SPY over 10 years, with commission and slippage:

50/200 crossBuy and hold
Total return+97.2%+260.9%
Per year7.0%13.7%
Worst drop−29.3%−34.1%
Trades4—

The agent’s verdict: it didn’t beat buy and hold. It softened the worst drop a little but gave up most of the gain, and four trades in ten years are too few to judge by. That is the useful kind of answer — it stops you relying on an idea that sounds good.

How to do it

  1. Connect TradePuffin to your AI app (Claude, ChatGPT, Claude Code).
  2. Describe the rules in plain words: when to buy, when to sell, which symbols, how many years.
  3. The agent picks a built-in template or writes the rules as a short script, then calls backtest.
  4. Read the result next to buy and hold, then ask for the year-by-year breakdown and the trade list (get_backtest). The run is saved in your app too.
  5. Change one thing at a time — costs, period, symbols — and test again.

How to read a backtest honestly

Prompts to copy

Backtests are hypothetical and use past data; they don’t predict future results. The SPY figures are from a real run on TradePuffin, 10 years of daily bars to November 2026, with default commission (0.05%) and slippage (0.02%).

Try it with your own agent.7-day free trial. Connect Claude, ChatGPT, Gemini or Cursor in minutes.
Start free trial

More guides

For information and education only; not investment advice. See the Disclaimer.