Claude can backtest a strategy for you if it has a tool that runs backtests. ENSEMBLE provides one as a hosted MCP server, and connecting it takes about two minutes in Claude Desktop or one command in Claude Code. After that, describing a strategy in the conversation produces a real model with a public tear sheet, and asking Claude to change something produces a revised one. This guide covers the setup for both clients and then walks through a real session, including the places where the agent needed correcting.
Setup in Claude Desktop or claude.ai
- Open Settings, then Connectors, then Add custom connector.
- Paste
https://api.ensemble.markets/mcpas the URL and click Add. - Claude opens the ENSEMBLE sign-in. Sign in or create an account. There are no keys to copy; the connection uses OAuth 2.1.
- Start a new conversation. The ENSEMBLE tools are now available, and Claude will mention them when relevant.
The Free plan allows one custom connector; paid plans allow several. If you already have a connector configured and are on Free, you will need to remove it first.
Setup in Claude Code
From a terminal:
claude mcp add --transport http ensemble https://api.ensemble.markets/mcp
The first time a tool is called, Claude Code opens a browser for the ENSEMBLE sign-in. For headless or scripted use, create an ensemble_ API key in the dashboard and add it as a header instead:
claude mcp add --transport http ensemble https://api.ensemble.markets/mcp \
--header "Authorization: Bearer YOUR_API_KEY"
Run /mcp inside Claude Code to confirm the server is connected and to see its tools.
A real session
What follows is a representative session in Claude Desktop, reconstructed around the real tool results for the dual momentum model published on this site. The user's messages are in bold. Tool calls are summarized in brackets; in Claude's interface the actual calls and results are visible if you expand them.
Backtest dual momentum on US and international stocks with a T-bill fallback.
I'll build that as a strategy. To make it testable I'm going to specify: SPY and EFA as the two equity funds, BIL as the cash position, a 12-month total-return lookback, and monthly evaluation at month end. Let me confirm those tickers exist and check their history first.
[calls
list_assetsfor SPY, EFA, BIL]All three are available. SPY and EFA both have data from 2001, so the tear sheet will open there; BIL launched in May 2007 and joins then. Building now.
[calls
create_modelwith: "Dual momentum across SPY, EFA and BIL: hold whichever of SPY and EFA has the higher 12-month total return, and move to BIL when the leader's 12-month return is negative. Rebalance monthly."]The build is running. I'll check on it.
[polls
get_modelthree times over about 40 seconds]Done. Here's what the model shows over May 2007 through the latest session:
- CAGR and volatility are on the tear sheet; the Sharpe ratio is about 0.5 and the maximum drawdown is around a third, versus roughly 55 percent for SPY over the same window.
- The run metadata shows about two rebalances per year on average, not twelve. That's expected: the rule is evaluated monthly but only trades when the signal changes.
- The QA note flags exactly that: the description says "monthly" and the backtest measured about 2 trades a year. That's the rule working as intended, but worth knowing if you expected more turnover.
The full tear sheet is at the link, including the equity curve against SPY, the drawdown chart, and the months it spent in each fund.
Two things in that answer are worth noticing. Claude confirmed the universe and the start date before building, which is the first habit of a careful backtest. And it read the run metadata and the QA finding rather than stopping at the headline metrics, which is how it caught the difference between "evaluated monthly" and "trades monthly."
What if we use a 6-month lookback instead?
I'll rebuild the model rather than build a new one, so the two versions stay linked.
[calls
rebuild_modelwith the same description and "6-month" in place of "12-month"][polls
get_model]Here are the two tear sheets side by side. Compare the rebalances per year first: the shorter lookback reacts faster to turns and switches more often, and every switch is a cost. Then compare the drawdown charts and the compound returns over the same window. Whichever version looks better here, that's one sample, not a verdict; a different twenty years could rank them the other way.
The last sentence is the one to look for. An agent that says "the 12-month version is better" is overfitting on your behalf. One that says "over this window" is doing research. If Claude does not add the caveat, ask it what the difference would look like over a different window, and it will usually reason correctly about sample dependence.
Add a 60/40 core and hold 70 percent core, 30 percent dual momentum.
That's a portfolio: a fixed core plus a strategy sleeve. I'll build the core as its own strategy first, then compose them.
[calls
create_modelwith "60% SPY and 40% TLT, rebalanced quarterly"][polls, then calls
create_modelwith: "Hold 70% in m-… (the 60/40 core) and 30% in m-… (the dual momentum strategy), rebalanced quarterly."]The portfolio's tear sheet is ready. Its holdings chart shows the equity weight stepping down whenever the dual momentum sleeve moves to T-bills, and the look-through allocation shows the actual asset weights at any date. Compare its drawdown chart with the two components' to see what the 30 percent sleeve changed.
This is the platform's composition model in one exchange: a model holds assets, other models, or both. Claude understood that "add a core" meant composition, not a more complicated single rule.
Prompts that get good results
The agent is only as precise as your request. These patterns produce testable models on the first try.
- Name the universe. "SPY, EFA and BIL" rather than "US and international stocks and cash." If you do not know the tickers, ask Claude to suggest liquid ETFs and confirm before building.
- Name the lookback and the cadence. "12-month return, evaluated at month end" rather than "recent performance."
- Say what happens when the signal is off. "Hold BIL" rather than leaving it implicit.
- Ask for one change at a time. "Change the lookback to 6 months" rather than "try some variations." The second produces a lot of models and no comparison.
- Ask Claude to read the code when a result surprises you.
get_buildreturns the implementation (get_modelnames the currentbuild_id), and Claude can explain what the rule actually did.
The common backtesting mistakes guide applies to agents as much as to people; an agent can overfit faster than you can.
Prompts to avoid
- "Find me the best strategy." This invites the agent to run many builds and report the winner, which is data snooping. Ask it to test a specific idea instead.
- "Optimize the parameters." Same problem. If you want to know how sensitive a result is to a parameter, ask for two or three conventional values and compare.
- "Should I invest in this?" The agent will decline, correctly. ENSEMBLE is research software, the backtests are hypothetical, and neither the platform nor Claude gives investment advice.
Reading what comes back
Whatever Claude summarizes, open the tear sheet. The metrics explained guide defines every figure on it. Check the start date against the funds' launch dates (get_model reports the window and which fund set it), check the universe against what you asked for, look at the drawdown chart before the return, and look at the trade count before believing the return survives costs. Claude is good at doing this for you and better at doing it when you ask.
Backtests are hypothetical, past performance does not guarantee future results, and ENSEMBLE is research software rather than an investment adviser.
Frequently asked questions
- Does this work on the free Claude plan?
- Yes. Claude Free allows one custom connector, which is enough for ENSEMBLE. Paid plans allow more. Claude Code works with any plan that includes it.
- Do I need an ENSEMBLE account?
- Yes, for MCP. The sign-in step creates one if you do not have it, and every account starts with $100 in credit and no card required.
- Can Claude place trades based on the backtest?
- No. ENSEMBLE's tools build, backtest, and read models. Nothing connects to a brokerage, and no tool executes an order. Claude can tell you what a model's current target allocation is; acting on it is up to you.
- Why does Claude poll for results instead of getting them immediately?
- A build takes 20 to 120 seconds, which is longer than many MCP transport timeouts. The create tool returns immediately with a building status, and Claude checks get_model every few seconds until the model is ready. This is the intended behavior, not a stall.
Related
- AI agentsWhat is a finance MCP server, and is there one for backtesting?
A finance MCP server gives an AI assistant tools for investment research. This guide explains how MCP works, what separates a data-lookup server from a backtesting server, hosted versus local servers, authentication, and the tools ENSEMBLE's server exposes.
- StrategiesDual momentum: the rules, the evidence, and a backtest
Dual momentum combines relative momentum (hold the recent winner) with absolute momentum (move to cash when the winner is falling). Here are the exact rules, why it works, when it fails, and a hypothetical backtest you can rerun.
- BacktestingCommon backtesting mistakes and how to avoid them
The ways a backtest lies: lookahead bias, survivorship bias, overfitting, ignored costs, short or regime-limited samples, and misread metrics. What each one looks like, how to detect it, and what a backtesting tool can and cannot protect you from.
- BacktestingBacktest metrics explained: CAGR, volatility, Sharpe ratio, and max drawdown
What each number on a backtest tear sheet means, how it is computed, what a reasonable range looks like for a diversified portfolio, and how the metrics mislead when read alone. Definitions for CAGR, volatility, Sharpe ratio, maximum drawdown, turnover, and time in market.