How to backtest with Claude on real stock data
Claude can reason about a trading idea, but it cannot test one without market data and a backtest engine. Connect it to QuantGPT, ten minutes and three ways in, and it runs backtests on decades of real US stock data. When the AI light in the terminal nav goes green, you are armed.
Updated October 27, 2026 · limits by plan under LIMITS AND BOUNDARIES
In one line: add QuantGPT to Claude as a connector, one URL and a sign-in. Claude can then search the Strategy Library, run backtests on decades of US stock data, change a setting and run again, and tell you what held up on the years it did not test on.
The setup is right below. No connector option on your plan? Use the paste-pack.
// CLAUDE CODE (TERMINAL)
claude mcp add --transport http quantgpt https://terminal.quantgpt.co/mcp
- Run the line above, then start claude.
- Type /mcp, pick quantgpt and choose Authenticate. Your browser opens QuantGPT's own sign-in; if it opens the wrong browser, Claude Code prints the link, so you can paste it into the one you are signed in on.
- Sign in and press CONNECT. Back in Claude Code, quantgpt shows as connected.
- Ask it to call describe_capabilities. It starts with the core desk; ask it to call available_categories when a task needs the equity, portfolio, macro or alt-market tools, and it switches them on for your account.
The connection appears as a key on your account page, where you can revoke it.
For scripts and servers, where nobody is there to sign in, use a key instead: on your account page, under Keys for your AI, type a label and press Issue key, and copy the qg_sk_... value at once (only its hash is stored). Then:
claude mcp add --transport http quantgpt https://terminal.quantgpt.co/mcp --header "Authorization: Bearer qg_sk_YOUR_KEY"
// CLAUDE DESKTOP AND CLAUDE.AI
- Open Customize, then Connectors.
- Click + and choose Add custom connector. On a Team or Enterprise plan an Owner may need to add it first.
- Name it QuantGPT. URL: https://terminal.quantgpt.co/mcp. Leave the OAuth client fields empty and click Add.
- Press Connect. Claude opens QuantGPT's sign-in page: sign in and approve. The connection shows on your account page as a key labelled connector: Claude, and you can revoke it there.
- Start a new conversation and ask Claude to call describe_capabilities.
// PROVE IT WORKED
"Using QuantGPT: call the guide tool and walk me up THE RAMP from wherever I am. Then run a classic momentum study, 1990 start, and state plainly what failed."
Back in the terminal, the AI light in the nav turns green after the first call. That is RAMP 05 and 06 done.
// WAYS TO GIVE CLAUDE STOCK DATA, COMPARED
| WAY | WHAT CLAUDE GETS | RUNS A BACKTEST | SETUP |
|---|---|---|---|
| QuantGPT connector (claude.ai, Claude Desktop, Claude Code) | The QuantGPT data and backtest engine, on your account | Yes, Claude calls the tools itself | Add one URL and sign in |
| QuantGPT key (scripts and servers) | The same tools | Yes | One command with your key; you keep the key safe |
| QuantGPT paste-pack | The context and the curriculum, as text | No, it guides you through the terminal | Copy one block |
| A market data service plus scripts Claude writes | Whatever the service sends | Only if you build the engine | You run the code and paste results back |
| Uploading a CSV | Only the file you upload | Only what it can work out in the chat | None |
If you want Claude to run backtests on real history without building anything, use the connector, or the key for scripts. If you only want Claude to walk you through the steps, use the paste-pack.
// WHAT A BACKTEST GIVES BACK
When Claude runs a backtest through QuantGPT, the answer comes back with the numbers that produced it:
- Growth a year, the worst drop and the Sharpe ratio (how much return for the bumps along the way), each beside the S&P 500 with dividends reinvested.
- A check on years it was not tested on. The history is split at a year, 2015 unless you pick another, and the years after it are scored on their own.
- Decade by decade, so one great stretch cannot hide a bad one.
- Results after trading costs at four cost levels, and the exact number of trades. The headline numbers are gross of costs.
- The finding. DATA VALIDATED means it beat the S&P 500 on growth and on Sharpe and held up in the later years; TRADE-OFF means it won on one of the two; NO EDGE means it won on neither.
Here is a real one, run on October 27, 2026: the 200-day rule on SPY, the S&P 500 fund. At each month end it holds SPY while the price is above its average of the last 200 trading days, and cash while it is below. From January 1998 to September 2026, against the S&P 500 with dividends, gross of costs:
- Growth a year8.97% against 9.38% for the S&P 500
- Worst drop23.0% against 50.9%
- Sharpe ratio0.88 against 0.66
- From 2015 on8.91% a year against 14.17%, Sharpe 0.84 against 0.97
- FindingTRADE-OFF
TRADE-OFF here means the rule gave up 0.41 points of growth a year for less than half the worst drop and a higher Sharpe ratio. Claude reads you all of it, and can then change one setting, such as the start year or the benchmark, and run it again in the same conversation.
// WHY THE DATA MATTERS
A backtest on only the companies that still trade today looks better than the market really was, because the ones that failed are missing. In QuantGPT's market-wide backtests, companies that later delisted are included from 1998 on: 12,521 of the 12,841 with prices, or 98%. Before 1998 the data holds only companies that survived. Company numbers such as earnings are used from the day they were filed, so a backtest only sees what was known at the time.
// OTHER ASSISTANTS
The same server connects to other AI apps too. Step-by-step guides: ChatGPT · Gemini · Cursor.
// LIMITS AND BOUNDARIES
AI calls are counted per account, across all your keys and connections: 500 a day on QuantGPT and 1,500 a day on QuantGPT Pro, the 3-day trial included. No tool your AI can call places, modifies, or cancels an order; a few save things to your own QuantGPT account, such as a saved study or an alert. Rotate keys from the account page any time (1 active key on Free, 3 on QuantGPT, 5 on QuantGPT Pro).
// QUESTIONS
Can Claude backtest a trading strategy?
Claude can design and explain a strategy on its own, but to test one it needs market data and a backtest engine. Connected to QuantGPT over MCP, it runs the backtest on decades of real US stock data and reads you the result.
What is the easiest way to give Claude stock market data?
For backtests, a connector. In claude.ai or Claude Desktop you add one URL, https://terminal.quantgpt.co/mcp, and sign in. For a one-off lookup, a script against a market data service also works, but you run it and paste the results back.
Do I need an API key to connect Claude to QuantGPT?
No. claude.ai, Claude Desktop and Claude Code all sign in to QuantGPT, and the connection shows on your account page, where you can revoke it. A key is for scripts and servers, where nobody is there to sign in. The paste-pack needs neither.
Can I just upload a CSV of prices to Claude?
It works for a small, fixed set of prices. A backtest across many stocks and many years needs far more data than a file upload holds, and a list of today's tickers leaves out the companies that later delisted.
What does a QuantGPT backtest tell me?
Growth a year, the worst drop and the Sharpe ratio, each beside the S&P 500 with dividends; the same numbers for the years held back from the test; a decade by decade table; results after trading costs; the trade count; and the finding: DATA VALIDATED, TRADE-OFF or NO EDGE.
What does it cost?
QuantGPT is $49 a month and QuantGPT Pro $149 a month, each starting with a 3-day free trial with a card up front, cancel any time. Your AI gets 500 calls a day on QuantGPT and 1,500 on QuantGPT Pro, the trial included.
Can Claude place trades through QuantGPT?
No. No tool Claude can call places, modifies or cancels an order.
Backtests are hypothetical and gross of trading costs unless stated; past results do not predict future ones. Setup steps checked October 27, 2026; Claude's menus can change.