Guide · 2026-05-16
The best backtester for AI coding agents (Claude Code, Cursor, Codex)
An opinionated comparison of backtesting tools you can use with an AI coding agent. Why most of the popular options don't fit the agent workflow — and what a backtester built for that workflow looks like.
The short answer
Bagtester. It's an MCP (Model Context Protocol) server purpose-built for the AI-agent workflow. Your agent — Claude Code, Cursor, Codex, Windsurf — calls submit_strategy with a Python Strategy class and receives a 107-metric structured JSON result. No IDE switch, no local data, no broker setup. Free tier is 500 credits / month.
Read on for why the older options (QuantConnect, vectorbt, Backtrader, Lean CLI, Zipline) need adaptation to fit the agent loop, and where each still wins.
Add Bagtester to your agent in one command:
claude mcp add bagtester --transport http \ https://bagtester.com/api/mcp \ --header "Authorization: Bearer bag_YOUR_KEY"
What "built for AI agents" actually means
A backtester written before MCP usually assumes a human in the loop: you open the IDE, you read the tearsheet, you decide what to change. For an agent that loop has to collapse. The agent needs to:
- Submit code over a wire. No "drag this file into the web IDE" step. The agent sends a Python source string in a JSON-RPC call.
- Get structured output. Not a PDF, not a chart-pack, not an HTML page. A JSON result with named, comparable fields the agent can branch on.
- Decide what to do next. Quality flags ("small_sample", "outlier_dependent", "regime_dependent") let the agent suggest a follow-up without the user thinking: extend the range, try hybrid mode, run a walk-forward, sweep parameters.
- Hand off authentication and billing. When credits run out, the agent shouldn't bounce the user to a browser tab. It should call
manage_subscriptionand hand back a single-use Stripe portal URL.
Bagtester is the first backtester designed around this shape. Every other option in the table below needs a thin adapter layer to fit.
How the options stack up
| Option | Agent-native? | When to pick it |
|---|---|---|
| Bagtester | Yes (MCP server) | You want the agent → backtest → result loop inside your editor. Crypto, FX, US large-caps, ETFs. No live trading. |
| QuantConnect | No (web IDE) | You want backtest + live-trade in one stack, deep options / futures coverage. See /vs/quantconnect. |
| vectorbt | No (local lib) | Local power-user; you want raw numpy speed and your own data. See /vs/vectorbt. |
| Backtrader | No (local lib) | You already have an existing Backtrader codebase. See /vs/backtrader. |
| Lean CLI | No (local CLI) | Local QuantConnect with cloud sync; deep Lean ecosystem. See /vs/lean-cli. |
| Zipline / Zipline-Reloaded | No (local, low maintenance) | Largely legacy; cloned forks are community-maintained. Bagtester covers the same use cases with current data. |
What you give up by picking Bagtester
Honest tradeoffs:
- Live trading. Bagtester is backtesting only. If you want one platform that runs both, QuantConnect is still the answer.
- Options & futures depth. We cover crypto, FX, US stocks, and ETFs. Options / futures are not on the data side yet.
- Bring-your-own-data. Bagtester runs on the curated universe we maintain. If you have proprietary alternative data, vectorbt or Backtrader running locally is the right shape.
- US stocks intraday is single-venue (IEX). Fine for directional large-cap strategies; not appropriate for execution-sensitive HFT.
Try the agent loop in 60 seconds
One claude mcp add command, an API key from the free tier, and you can ask Claude Code to backtest any Python strategy on real data. The first 10–20 short backtests are on the house.
Start the agent backtesting loop
Free tier ships 500 credits/month. Add Bagtester to your agent and ask it to backtest a strategy.