# Can ChatGPT or Claude backtest a trading strategy?

> Yes, with one catch. How to use ChatGPT, Claude or another AI assistant to build and backtest a strategy on real prices, and which results to trust.

Written by [Tactfolio research team](https://tactfolio.com/about/editorial-policy.md), published 2026-10-16, updated 2026-10-16.

Yes, you can use ChatGPT or Claude to build and backtest a trading strategy, with one catch. On its own, a chat assistant can explain a strategy and write backtest code. It should never be trusted to make up results from memory. The numbers need to come from real prices and a real test. The safest way is to connect the assistant to a backtesting tool, so it builds the rules and the tool runs the test.

## Key points

- A [backtest](https://tactfolio.com/learn/backtesting-explained.md) replays a rule on past prices. An AI assistant cannot do that from memory.
- An assistant can write Python code that runs a backtest on price data you give it. You then have to check the data and the code.
- Through MCP, an assistant can use a real backtesting tool for you. MCP is a standard way for AI assistants to use other apps.
- On Tactfolio, an AI assistant connected through MCP can build, test and save strategies in your account for free. Setup steps cover nine assistants, including Claude, ChatGPT and Codex.
- An AI can try many versions of a rule very fast. That raises the odds of finding a rule that fits the past by luck.

## Can ChatGPT backtest a trading strategy?

ChatGPT can help you backtest a trading strategy, but it cannot do it alone in a plain chat. A language model writes the most likely next words. It does not look up prices or run the trades unless it has a tool for that.

So if you ask a plain chat "how did dual momentum do since 2008?", the answer may sound exact and still be wrong. The model may mix up dates, funds or numbers it saw in its training text. Treat any return figure from a chat with no tool as a guess.

The same is true for Claude, Gemini and every other assistant. What matters is the tool the assistant uses, not the brand of the assistant.

## Three ways to backtest with an AI assistant

There are three ways people use AI for backtesting. They differ in where the numbers come from.

| Way | What the AI does | Where the numbers come from | Main risk |
| --- | --- | --- | --- |
| Ask in a plain chat | Describes the strategy and guesses results | The model's memory | Made-up or outdated figures |
| Ask it to write code | Writes Python, and may run it on a file you upload | The price file you supply | Bad data, bugs and look-ahead errors you must catch |
| Connect it to a backtester | Builds the rules and asks the tool to test them | The tool's price data and test engine | Testing too many versions and fooling yourself |

### 1. Ask in a plain chat

This is fine for learning. Ask the assistant to explain a strategy, list its rules or name the paper it came from. Then check the source yourself. Do not use the numbers.

### 2. Ask it to write backtest code

Both ChatGPT and Claude can write and run Python code on a file you upload. You can download daily prices, upload them, and ask for a backtest. This works, but you own every step. Check that prices include dividends and that trading costs are counted. Also check that the rule only uses data it could have known that day. One wrong line can make a weak rule look great.

### 3. Connect the assistant to a backtesting tool

This is the most reliable way. The assistant writes the rules in the tool's own format, and the tool runs the test on its own data. You get the same numbers you would get by clicking through the tool yourself. MCP, short for [Model Context Protocol](https://modelcontextprotocol.io/), is the open standard that makes this possible.

## How to backtest a strategy with Claude on Tactfolio

Tactfolio has an MCP server, so an AI assistant can work in your account. Here is how it goes.

1. **Connect your assistant.** Add Tactfolio's address, https://tactfolio.com/mcp, to your assistant. [Use Tactfolio from your AI assistant](https://tactfolio.com/docs/mcp.md) has the steps for each one. Claude, Cursor and VS Code have one-click buttons.
2. **Approve access.** Your browser opens Tactfolio and asks you to allow it. There is no API key to copy.
3. **Describe your idea in plain words.** For example: "Hold QQQ while it is above its 50-day average and the VIX is under 25. Otherwise split between IEF and BIL. Backtest it from 2010 and save it as a draft."
4. **Read the result.** The assistant builds the strategy, runs the backtest and saves a draft.
5. **Check it yourself.** Open the draft in the [builder](https://tactfolio.com/builder). Read every rule and look at the worst drop, not only the final return.

Backtests on Tactfolio use daily prices of US-listed stocks and ETFs, with dividends reinvested and a 0.05% cost on every trade. The assistant uses the same builder and the same backtests as you do. [AI trading on Tactfolio](https://tactfolio.com/ai-trading.md) explains what the assistant can and cannot do.

## Which AI assistants work with Tactfolio?

Any assistant that can add a remote MCP server with browser sign-in can work with Tactfolio. [Our setup guide](https://tactfolio.com/docs/mcp.md) has steps for nine assistants. This is what we checked as of October 16, 2026:

| Assistant | Status on Tactfolio |
| --- | --- |
| Claude Code (Anthropic) | Setup steps tested |
| Codex (OpenAI) | Setup steps tested |
| OpenCode | Setup steps tested |
| Claude app (custom connector) | Sign-in checked |
| ChatGPT app (custom connector) | Sign-in checked |
| Cursor, VS Code and Gemini CLI | Sign-in checked |
| Cline | Setup steps listed, not yet checked by us |

"Sign-in checked" means Tactfolio accepts the app and sends you to sign in. We have not yet run a full session in each of those apps.

Anthropic says the Claude app can add custom connectors that use remote MCP on its Free, Pro, Max, Team and Enterprise plans. Free users can add one. See [Anthropic's help page](https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp) for the current rules.

## Why an AI makes overfitting easier

An AI assistant can test fifty versions of a rule in the time you test one. That speed is useful. It also raises the odds of finding a rule that fit the past by luck. This is called overfitting, or curve fitting.

Here is a simple guard. Tell the assistant to tune the rule on older years only. Then test the winner once on recent years it has not seen. This is called an out-of-sample test. Our guide to [why past results mislead](https://tactfolio.com/docs/concepts/why-past-results-mislead.md) covers this and other traps.

A good prompt also says why the rule should work. "Bonds should do better when stocks trend down" gives the assistant an idea to test. "Find the best moving average" asks it to fit noise.

## Common mistakes when an AI builds your strategy

- **Trusting a number the AI wrote without a tool.** Ask where the figure came from. If the answer is "my knowledge", do not use it.
- **Not reading the rules.** An assistant may change a detail you did not ask for, like the rebalance day. Open the strategy and read it.
- **Looking only at the return.** Check the [maximum drawdown](https://tactfolio.com/learn/max-drawdown.md) and the bad years too.
- **Skipping costs.** A rule that trades every day can look great before costs and poor after them.
- **Letting it trade real money first.** Run a new strategy on [paper trading](https://tactfolio.com/paper-trading.md) before you use real money.

Regulators also warn about AI hype in investing. A joint alert from the SEC, NASAA and FINRA warns about claims that AI can guarantee big returns. As [FINRA's alert](https://www.finra.org/investors/insights/artificial-intelligence-and-investment-fraud) puts it: "Investment claims that sound too good to be true usually are." A backtest, made by you or by an AI, is hypothetical.

## Try it on Tactfolio

Open the [builder](https://tactfolio.com/builder) and try a starter pattern to see a backtest without an account. When you are ready, [connect an AI assistant](https://tactfolio.com/docs/mcp.md) and ask it to rebuild a strategy you like, such as [dual momentum](https://tactfolio.com/strategies/dual-momentum.md). Then compare its draft with the original.

## Common questions

### Can ChatGPT predict stock prices?

No. ChatGPT and other assistants cannot see the future, and their training text ends at a past date. They can help you write and test rules. They cannot tell you what a stock will do next.

### Is it safe to let an AI trade for me?

On Tactfolio, the AI does not trade. It writes and tests rules, and you decide what runs. A strategy you choose to run then follows its fixed rules once a day, in a paper account or your own Alpaca account.

### Do I need to code to backtest with AI?

No. With Tactfolio, you describe the idea in plain words and the assistant builds it from the same blocks you would click. If you ask a plain chat to write Python instead, you will need to read and check the code.

### Is backtesting with an AI assistant free?

Tactfolio's MCP server is free with your account while we build. Your assistant may have its own price. Check the plan you use with Claude, Codex or another assistant.

### Can ChatGPT connect to Tactfolio?

Yes, as a custom connector with the address https://tactfolio.com/mcp. On October 16, 2026, we checked that ChatGPT reaches Tactfolio's sign-in page. We have not yet run a full session in ChatGPT. [Use Tactfolio from your AI assistant](https://tactfolio.com/docs/mcp.md) has the ChatGPT steps. Whether you can add a custom connector depends on your ChatGPT plan and settings.

## Put it into practice

- [QQQ: Invesco QQQ Trust, Series 1](https://tactfolio.com/etf/qqq.md): What QQQ holds, its 0.18% yearly fee, returns by year, its worst drop, and which Tactfolio strategies hold it.
- [IEF: iShares 7-10 Year Treasury Bond ETF](https://tactfolio.com/etf/ief.md): What IEF holds, its 0.15% yearly fee, returns by year, its worst drop, and which Tactfolio strategies hold it.
- [BIL: State Street SPDR Bloomberg 1-3 Month T-Bill ETF](https://tactfolio.com/etf/bil.md): What BIL holds, its 0.1353% yearly fee, returns by year, its worst drop, and which Tactfolio strategies hold it.

## Sources

- [What is the Model Context Protocol (MCP)?](https://modelcontextprotocol.io/docs/getting-started/intro), Model Context Protocol, accessed 2026-10-16
- [Getting started with custom connectors using remote MCP](https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp), Anthropic, accessed 2026-10-16
- [Create and edit files with Claude](https://support.claude.com/en/articles/12111783-create-and-edit-files-with-claude), Anthropic, accessed 2026-10-16
- [Artificial Intelligence (AI) and Investment Fraud](https://www.finra.org/investors/insights/artificial-intelligence-and-investment-fraud), SEC, NASAA and FINRA, accessed 2026-10-16
- [Use Tactfolio from your AI assistant](https://tactfolio.com/docs/mcp), Tactfolio, accessed 2026-10-16
- [What a backtest simulates](https://tactfolio.com/docs/backtests), Tactfolio, accessed 2026-10-16
