Skip to main content

Backtesting with your agent

You don't need a data pipeline to test a strategy idea. Connect DataMaxi+ to your agent, describe the strategy, and the agent pulls the history it needs, writes the test and shows you the result. You stay in charge of the assumptions; the agent does the plumbing.

What it costs​

History calls are cheap and capped per call, so you can estimate the bill before you start:

DataPer call1 year × 5 venuesCost
Funding history100 rows11 calls per venue: 55$0.0275
Daily candles1,000 candles1 call per venue: 5$0.0025
Total≈ 60 History calls≈ $0.03

A year of 8-hour funding settlements is 1,095 rows per venue, so 11 pages of 100. Each History call (funding_rate_history, cex_candle) costs $0.0005.

The $5 sign-up credit covers about 160 backtests of that size. Hourly settlements or 1-hour candles take more pages: 8,760 hourly funding rows per venue is 88 calls, and a year of 1-hour candles is 9 calls of 1,000.

Limits to plan around (also on Rows per call):

  • Funding history: at most 100 rows per call; page with page or move from/to.
  • Candles: at most 1,000 per call, and only from 2024-01-01.
  • Liquidation history per symbol: 15m buckets cover up to 72 h, 1h buckets up to 7 days, so liquidations suit short event studies, not multi-year tests.

1. Connect DataMaxi+​

Add the MCP server to your client with your API key (one command for Claude Code; full setup for Claude, ChatGPT and Cursor on the MCP page):

claude mcp add datamaxi --transport http https://mcp.datamaxiplus.com/mcp \
--header "X-DTMX-APIKEY: YOUR_API_KEY"

2. Describe the test​

Be specific about the universe, the window, the rules and the costs. For example:

Backtest a delta-neutral funding carry on BTC-USDT perps over the last 12 months on Binance, Bybit, OKX, Bitget and Gate. Pull the funding history with DataMaxi+ (funding_rate_history, 100 rows per call, page until you have the full year) and daily candles with cex_candle. Each day, hold the venue with the highest trailing 7-day average funding; switch only when another venue beats it by 5% APR. Charge 0.1% per switch. Report annualized return, max drawdown and number of switches, and plot equity versus always holding Binance. Tell me how many DataMaxi+ calls you made.

A good agent will:

  1. Call funding_rate_exchanges / funding_rate_symbols (free) to confirm the venues and symbol.
  2. Page funding_rate_history per venue until the window is covered, and fetch candles with cex_candle.
  3. Run the test in its own sandbox or your local Python, and show the code so you can check it.
  4. Optionally call get_usage (free) to report what the run cost.

3. Check the result like a skeptic​

  • Look-ahead. Signals must only use data available at decision time (trailing averages, not centered ones).
  • Costs. Include fees, slippage and transfer time. Funding carry that survives 0.1% per switch is more believable than one that needs zero.
  • Settlement intervals. Venues settle every 1, 4 or 8 hours; compare in APR, not per-period rates.
  • Coverage. A venue that listed the pair mid-window has a shorter history; make the agent say so.

Doing it yourself over the API​

The same pull in plain Python, if you'd rather run the test in your own code:

import os
import time
import requests

API = "https://api.datamaxiplus.com/api/v1"
HEADERS = {"X-DTMX-APIKEY": os.environ["DATAMAXI_API_KEY"]}
VENUES = ["binance", "bybit", "okx", "bitget", "gateio"]
FROM = "2025-11-20"
TO = "2026-11-20"


def funding_history(exchange, symbol="BTC-USDT"):
rows, page = [], 1
while True:
r = requests.get(
f"{API}/funding-rate/history",
headers=HEADERS,
params={"exchange": exchange, "symbol": symbol, "from": FROM, "to": TO,
"limit": 100, "page": page, "sort": "asc"},
timeout=15,
)
if r.status_code == 402:
raise SystemExit("Balance empty: top up at https://datamaxiplus.com/dashboard/billing")
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", "60")))
continue
r.raise_for_status()
batch = r.json()["data"] # [{"d": unix_seconds, "f": rate}, ...]
rows += batch
if len(batch) < 100:
return rows
page += 1


history = {v: funding_history(v) for v in VENUES}
for venue, rows in history.items():
apr = sum(r["f"] for r in rows) * 100 # sum of one year of settlements, in %
print(f"{venue:8s} {len(rows):5d} rows {apr:6.1f}% simple annual funding")

Each page is one History call ($0.0005), whatever it returns. 429 responses are free; 402 means the balance is empty.