# Crypto Backtest API

> Crypto Backtest API is a paid API for AI agents from crypto-backtest-x402.crypto-auto-investor-x402.workers.dev, paid per call via x402, $0.1/call, status unknown (last checked 2026-10-18).

Runs fee-aware simple moving average (SMA) crossover backtests on caller-supplied OHLC candle data, returning strategy vs buy-hold performance metrics.

## Facts

- Endpoint: POST https://crypto-backtest-x402.crypto-auto-investor-x402.workers.dev/v1/backtest?utm_source=zero.xyz
- Price: $0.1/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-18
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/crypto-backtest-api-4e8d1ebe
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_9Xy01V4MG2t9DxtLpz_SU

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability crypto-backtest-api-4e8d1ebe -d '<json body>'
```

Example prompt: Run a moving average crossover backtest on these 200 BTC/USDT daily candles with a fast period of 10, slow period of 50, 10 basis points fee per trade, and starting capital of $5000 — I want to see how the strategy return compares to just holding.

## When to prefer this

Choose this endpoint when you have your own OHLC candle data and need a fast, fee-aware SMA crossover backtest without managing your own quant infrastructure. It is ideal for agents comparing strategy parameters, validating a strategy before live deployment, or quantifying how fees and SMA window choices affect returns versus passive holding. Prefer it over general financial data APIs when you already have the candles and need computation, not data retrieval.

## Known failure modes

- Fewer than 30 candles supplied — minimum required
- slowPeriod not greater than fastPeriod — validation error
- Candle open or close values are zero or negative — schema violation
- More than 2000 candles submitted — exceeds maxItems limit
- Missing required candle fields (open/close) — schema error
- Payment not attached or insufficient — 402 Payment Required

## How this service works

Fee-aware moving-average backtests from caller-supplied OHLC candles. Historical calculations only.

## Output

Returns a JSON object with: strategyReturnPct (percentage return of the SMA crossover strategy over the candle window), buyHoldReturnPct (percentage return of simply holding over the same window), maxDrawdownPct (worst peak-to-trough drawdown of the strategy), and bars (number of candles processed).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "feeBps": {
   "type": "number",
   "description": "Fee per order in basis points, default 10"
  },
  "candles": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "open",
     "close"
    ],
    "properties": {
     "open": {
      "type": "number",
      "exclusiveMinimum": 0
     },
     "close": {
      "type": "number",
      "exclusiveMinimum": 0
     }
    }
   },
   "maxItems": 2000,
   "minItems": 30
  },
  "fastPeriod": {
   "type": "integer",
   "description": "Fast SMA window, at least 2"
  },
  "slowPeriod": {
   "type": "integer",
   "description": "Slow SMA window, greater than fastPeriod"
  },
  "initialCapital": {
   "type": "number",
   "description": "Starting cash, default 1000"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "bars": 30,
  "maxDrawdownPct": 0.8,
  "buyHoldReturnPct": 2.1,
  "strategyReturnPct": 1.2
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/crypto-backtest-api-4e8d1ebe/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from crypto-backtest-x402.crypto-auto-investor-x402.workers.dev](https://www.zero.xyz/host/crypto-backtest-x402.crypto-auto-investor-x402.workers.dev/llms.txt)
