canli-mcp / Backtests

How do I backtest a trading strategy in Claude?

Ask Claude to backtest it with canli-mcp. The backtest runs on your machine over real prices, reports return, Sharpe and drawdown, and counts every setting you tried, so it can tell you how much of the result luck would explain. In hosts that draw MCP Apps the sliders rerun it in place.

Free and MIT-licensed. No account and no API key. Or run claude mcp add canli -- npx -y canli-mcp in Claude Code.

Ask it

Backtest a 50/200-day moving-average crossover on SPY since 2010.

The agent finds the tool through canli-mcp's find_tool and runs it through run_tool. This is the call:

{
  "calls": [
    {
      "name": "price_history",
      "arguments": {
        "symbol": "SPY",
        "start": "2010-01-01"
      }
    },
    {
      "name": "backtest_ma_crossover",
      "arguments": {
        "prices": {
          "$result": 0,
          "path": "close"
        },
        "dates": {
          "$result": 0,
          "path": "dates"
        },
        "fast": 50,
        "slow": 200
      }
    }
  ],
  "return": "last"
}

What came back

Recorded from canli-mcp 0.11.1 on 2026-10-25, with no API key set. The model read 673 characters.

The result backtest_ma_crossover sent back
{
  "rule": "Long when SMA(50) > SMA(200), else flat.",
  "parameters": {
    "fast": 50,
    "slow": 200
  },
  "total_return": 3.36815,
  "cagr": 0.0918739,
  "volatility": 0.139311,
  "sharpe": 0.700949,
  "max_drawdown": -0.337171,
  "periods": 4227,
  "calmar": 0.272484,
  "annual_turnover": 0.894251,
  "average_exposure": 0.801041,
  "weight_changes": 15,
  "cost_drag_annual": 0.000447126,
  "buy_and_hold": {
    "cagr": 0.140016,
    "sharpe": 0.85516,
    "max_drawdown": -0.337171
  },
  "returns_tail": [
    0.0042319,
    0.00335299,
    0.00525323,
    -0.0118098,
    -0.00522279
  ],
  "caution": "One backtest of one parameter set. If you tried others, count them and use strategy_sweep or deflated_sharpe_ratio."
}

Prices, filings and statistics are as the sources published them on that day; run the call again for today's. Nothing here is investment advice.

The same answer as a view

In a host that draws MCP Apps, view: true shows the person the whole result and gives the model a summary. Watch it, then try it: below the clip is canli-mcp's real view, playing a recording.

Backtest lab

The view loads here.

The tools behind the answer

From canli-mcp's tool index
ToolPackWhat it does
price_historymarketsPrice bars (open, high, low, close, volume), daily to hourly, for US stocks and ETFs, stocks listed abroad (SAP.DE, 7203.T), currency pairs (EUR/USD), futures (crude oil, gold), indices and yields (S&P 500, VIX, 10 year yield) and crypto (bitcoin), by symbol or plain name. Stocks adjust for splits and dividends by default, with dividends, splits and the total return; returns: true adds daily returns. No key needed; uses the user's Alpaca or Tiingo key for US stocks when set.
backtest_ma_crossoverquantBacktest a fast/slow moving-average crossover on your prices with costs and no lookahead: CAGR, Sharpe, drawdown, turnover, cost drag and buy-and-hold for comparison.

Add canli-mcp

Claude Code
claude mcp add canli -- npx -y canli-mcp
Cursor, Claude Desktop or any MCP client
{ "mcpServers": { "canli": { "command": "npx", "args": ["-y", "canli-mcp"] } } }
claude.ai, ChatGPT or any client that takes a URL
https://canlicapital.com/mcp/canli

Everything canli-mcp does · How it compares with other finance MCP servers

Related questions