# Crypto Backtest

> Crypto Backtest is a paid API for AI agents from grok-backtest-api.fly.dev, paid per call via x402, $0.05/call, status unknown (last checked 2026-10-31).

Runs a historical backtest of a crypto trading strategy (breakout, momentum, or dip-buying) on Coinbase daily candles with survivorship-bias-free universe construction, returning PnL metrics and trade statistics.

## Facts

- Endpoint: POST https://grok-backtest-api.fly.dev/backtest?utm_source=zero.xyz
- Price: $0.05/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-31
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/crypto-backtest-8a293f51
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_oi9p0Ku_Amgxku3TEzhLN

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-8a293f51 -d '<json body>'
```

Example prompt: Run a backtest of a momentum strategy on crypto from January 2022 to December 2023, holding the top 5 tokens, with a 20-day lookback, rebalancing every 7 days, and a 10% trailing stop — use a BTC MA50 market gate and assume 0.1% slippage and 0.1% fees.

## When to prefer this

Choose this endpoint when you need to historically validate a crypto trading strategy (breakout, momentum, or dip-buying) on Coinbase daily candles with a survivorship-bias-free universe. Prefer it over generic backtesting tools when you need point-in-time universe construction that avoids lookahead bias, and when pay-per-call economics (no subscription) are preferred. Use it before deploying any systematic crypto strategy to quantify expected drawdown, win rate, and return.

## Known failure modes

- Invalid strategy type returns a validation error
- Date range with insufficient historical data may produce unreliable or empty results
- Slippage or fee values outside allowed range (0–0.05) are rejected
- Strategy parameters outside allowed bounds (e.g. lookback > 60) fail validation
- Payment not settled via x402 results in 402 Payment Required response

## How this service works

Backtest any crypto strategy on 399 Coinbase coins, bias-free. Breakout, momentum, dip-buy or MA trend rules on Coinbase daily data with fees, slippage, H1/H2 split, luck flag and survivorship-bias-free universe.

## Output

A JSON object containing total return percentage, final portfolio value, win rate, number of closed trades, maximum drawdown percentage, total fees paid, and a luck flag indicating whether the strategy's performance may be attributable to chance rather than edge.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "end": {
   "anyOf": [
    {
     "type": "string"
    },
    {
     "type": "null"
    }
   ]
  },
  "fee": {
   "type": "number",
   "maximum": 0.05,
   "minimum": 0
  },
  "start": {
   "anyOf": [
    {
     "type": "string"
    },
    {
     "type": "null"
    }
   ]
  },
  "slippage": {
   "type": "number",
   "maximum": 0.05,
   "minimum": 0
  },
  "strategy": {
   "oneOf": [
    {
     "type": "object",
     "required": [
      "type"
     ],
     "properties": {
      "type": {
       "type": "string",
       "const": "breakout"
      },
      "params": {
       "type": "object",
       "properties": {
        "gate": {
         "enum": [
          "none",
          "btc_ma50",
          "breadth50"
         ],
         "type": "string"
        },
        "atr_mult": {
         "type": "number",
         "maximum": 6,
         "minimum": 0.5
        },
        "lookback": {
         "type": "integer",
         "maximum": 60,
         "minimum": 5
        },
        "max_stop_pct": {
         "type": "number",
         "maximum": 0.9,
         "exclusiveMinimum": 0
        },
        "min_stop_pct": {
         "type": "number",
         "maximum": 0.5,
         "exclusiveMinimum": 0
        },
        "max_positions": {
         "type": "integer",
         "maximum": 10,
         "minimum": 1
        },
        "risk_per_trade": {
         "type": "number",
         "maximum": 0.25,
         "exclusiveMinimum": 0
        },
        "max_position_pct": {
         "type": "number",
         "maximum": 1,
         "exclusiveMinimum": 0
        }
       },
       "additionalProperties": false
      }
     },
     "additionalProperties": false
    },
    {
     "type": "object",
     "required": [
      "type"
     ],
     "properties": {
      "type": {
       "type": "string",
       "const": "momentum"
      },
      "params": {
       "type": "object",
       "properties": {
        "gate": {
         "enum": [
          "none",
          "btc_ma50",
          "breadth50"
         ],
         "type": "string"
        },
        "top_n": {
         "type": "integer",
         "maximum": 10,
         "minimum": 1
        },
        "lookback": {
         "type": "integer",
         "maximum": 60,
         "minimum": 3
        },
        "trail_pct": {
         "anyOf": [
          {
           "type": "number",
           "exclusiveMaximum": 0.9,
           "exclusiveMinimum": 0
          },
          {
         
… (truncated)
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "win_rate": 0.308,
  "fees_paid": 22.08,
  "luck_flag": true,
  "return_pct": 10.98,
  "final_value": 166.47,
  "closed_trades": 26,
  "max_drawdown_pct": -23.77
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/crypto-backtest-8a293f51/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from grok-backtest-api.fly.dev](https://www.zero.xyz/host/grok-backtest-api.fly.dev/llms.txt)
