Backtesting for AI coding agents
Your agent writes a strategy. We run it.
Submit a Python strategy through Claude Code, Codex, or Cursor. Get a standardized backtest in seconds — across crypto, FX, US stocks and ETFs, with realistic slippage, multi-mode execution, and research-grade tooling.
from bagtester import Strategy
class SmaCross(Strategy):
def __init__(self, fast=20, slow=50):
self.fast, self.slow = fast, slow
self.closes = []
def on_bar(self, ctx, bar):
self.closes.append(bar.close)
if len(self.closes) < self.slow: return
f = sum(self.closes[-self.fast:]) / self.fast
s = sum(self.closes[-self.slow:]) / self.slow
pos = ctx.position(bar.symbol)
if f > s and not pos:
ctx.buy(bar.symbol, ctx.equity * 0.95 / bar.close)
elif f < s and pos:
ctx.close(bar.symbol)> claude-code: backtest sma-cross on BTCUSDT 2024-2025
[mcp:bagtester] submit_strategy
✓ queued bt_3a7f...
✓ running on Bagtester worker
✓ completed in 11.4s
results:
total_return: +24.7%
sharpe: 1.83
max_drawdown: -14.2%
trades: 87
next_steps:
→ optimize_strategy {fast: [10,20,50], slow: [100,200]}
→ walk_forward to test out-of-sampleMCP-native
Built for agents
Asset coverage
Crypto · FX · US Stocks · ETFs
Execution modes
Minute · Hybrid · Tick
History depth
FX since 2003
What you get
A backtester your agent already knows how to use.
Pure Python, your way
Subclass bagtester.Strategy, write any logic. NumPy, pandas, polars, SciPy, scikit-learn, statsmodels, ta-lib, pandas-ta pre-installed.
Three execution modes
Minute (1× cost) for sketches, hybrid (3× cost) with adverse-fill realism, tick (10× cost) for HFT-grade execution on top crypto.
Standardized results
Sharpe, Sortino, max DD, win rate, equity curve, full trade log. Same shape every time so your agent can compare runs.
Parameter optimization
optimize_strategy ranks N parameter combinations by Sharpe, return, or your chosen metric. Pareto frontier in one call.
Walk-forward analysis
Roll a rolling-window in/out-of-sample test through a date range. Spot overfit before live trading.
Public sharing
One-click share links for any result with three privacy modes — metrics-only, named, or full code.
Execution modes
Pick how realistic you need fills to be.
Pay only for the realism you need. Same strategy code across all three.
Minute
Free+1× credits / single-symbol bar
Next-bar open + constant slippage
Quick iteration, parameter exploration, longer time horizons.
Hybrid
Trader+3× credits / single-symbol bar
Adverse-selection within OHLC range
More realistic execution slippage when iterating, without tick storage cost.
Tick
Quant10× credits / single-symbol bar
Full event-driven on tick stream
HFT realism for top crypto. FX tick mode lands next.
Simple pricing
$0 to start. $19 for serious. $39 for research-grade.
Free
$0
Get familiar with the workflow.
- ✓500 credits / month, rolling 30-day refresh
- ✓BTC, ETH, SOL — minute mode
- ✓MCP endpoint with one API key
- ✓7-day result retention
Trader
$19/mo
Multi-asset, hybrid execution, persistent strategies.
- ✓30,000 credits / month
- ✓Top 50 crypto + FX 16 majors + 200 US stocks + 50 ETFs
- ✓Hybrid mode unlocked
- ✓Parameter sweeps up to 50 combos
- ✓3 API keys, 5 concurrent backtests
- ✓Persistent strategy library
- ✓90-day result retention
Recommended
Quant
$39/mo
Tick execution + walk-forward + 300k credits.
- ✓300,000 credits / month — designed not to feel limiting
- ✓Tick mode on BTC, ETH, SOL
- ✓Parameter sweeps up to 1,000 combos
- ✓walk_forward (rolling out-of-sample tests)
- ✓Public result sharing + strategy comparison
- ✓Fundamentals data unlocked
- ✓10 API keys, 10 concurrent backtests
- ✓1-year result retention
Setup
Add Bagtester to your coding agent
We are an MCP server. Point your agent at our endpoint, drop in your API key, ask it to backtest something.
https://bagtester.com/api/mcpStop running backtests on your laptop.
Real data, realistic execution, structured outputs your agent can act on.