# x402stock Backtest

> x402stock Backtest is a paid API for AI agents from agents.x402stock.xyz, paid per call via x402, $0.5/call, status unknown (last checked 2026-09-14).

Backtests an SMA crossover or RSI mean-reversion strategy on a US stock ticker and returns a PNG equity-curve report with full performance statistics

## Facts

- Endpoint: GET https://agents.x402stock.xyz/api/v1/backtest/:ticker
- Price: $0.5/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402stock-backtest-ba6f9d06
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_-vhQpOvVc0FHm4h18hIAb

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 x402stock-backtest-ba6f9d06
```

Example prompt: Run an SMA crossover backtest on NVDA using a 50-day fast and 200-day slow moving average over the last 3 years starting with $10,000 capital, and show me the equity curve PNG comparing it to buy and hold.

## When to prefer this

Choose this endpoint when you need a quick, visual backtest of a standard technical strategy (SMA crossover or RSI mean-reversion) on a US equity with a rendered PNG report and hosted image URL. It is ideal for AI agents that need to present a chart artifact to users. Prefer alternatives if you need custom strategy logic, intraday data, options backtesting, or multi-asset portfolio simulation.

## Known failure modes

- Invalid or delisted ticker returns an error with no data
- fast SMA period >= slow SMA period may produce degenerate results
- years parameter exceeding 5 is rejected
- RSI lower >= upper threshold may cause validation error
- Insufficient historical data for requested period
- Payment of 0.5 USDC not confirmed results in 402 response

## How this service works

Backtests a simple rule on a US stock and returns a finished report PNG. Runs an SMA crossover (?strategy=sma_cross&fast=50&slow=200) or RSI mean-reversion (?strategy=rsi_reversion&period=14&lower=30&upper=70) over daily history (?years=, max 5), no lookahead, rendered as an equity curve vs buy & hold. Returns full stats plus a hosted `artifact.png_url`. From x402stock

## Output

Returns a hosted PNG image URL (artifact.png_url) showing the strategy equity curve plotted against a buy-and-hold baseline, plus full backtest statistics including returns, drawdown, and other performance metrics computed over the requested historical window with no lookahead bias.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "pathParams": {
     "type": "object",
     "ticker": {
      "type": "string"
     }
    },
    "queryParams": {
     "type": "object",
     "properties": {
      "fast": {
       "type": "integer",
       "default": 50,
       "maximum": 200,
       "exclusiveMinimum": 0
      },
      "slow": {
       "type": "integer",
       "default": 200,
       "maximum": 400,
       "exclusiveMinimum": 0
      },
      "lower": {
       "type": "number",
       "default": 30,
       "maximum": 99,
       "minimum": 1
      },
      "upper": {
       "type": "number",
       "default": 70,
       "maximum": 99,
       "minimum": 1
      },
      "years": {
       "type": "number",
       "default": 3,
       "maximum": 5,
       "exclusiveMinimum": 0
      },
      "period": {
       "type": "integer",
       "default": 14,
       "maximum": 100,
       "exclusiveMinimum": 0
      },
      "capital": {
       "type": "number",
       "default": 10000,
       "maximum": 1000000000,
       "exclusiveMinimum": 0
      },
      "strategy": {
       "enum": [
        "sma_cross",
        "rsi_reversion"
       ],
       "type": "string",
       "default": "sma_cross"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402stock-backtest-ba6f9d06/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.x402stock.xyz](https://www.zero.xyz/host/agents.x402stock.xyz/llms.txt)
