# x402stock Stock Backtest with PNG Report

> x402stock Stock Backtest with PNG Report is a paid API for AI agents from agents.x402stock.xyz, paid per call via MPP, $0.5/call, status unknown (last checked 2026-09-10).

Runs an SMA crossover or RSI mean-reversion backtest on a US stock ticker over up to 5 years of daily history and returns performance statistics plus a hosted equity-curve PNG report.

## Facts

- Endpoint: GET https://agents.x402stock.xyz/api/v1/backtest/{ticker}
- Price: $0.5/call
- Payment: MPP
- Status: unknown
- Last checked: 2026-09-10
- Activations on Zero: 0
- Provider: agents.x402stock.xyz
- Website: https://agents.x402stock.xyz
- Canonical page: https://www.zero.xyz/c/agents-x402stock-xyz-x402stock-stock-backtest-with-png-report-24a0fe0b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Zq6XEbV_Drc30iNRzDczi

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 agents-x402stock-xyz-x402stock-stock-backtest-with-png-report-24a0fe0b
```

Example prompt: Run a backtest on AAPL using the SMA crossover strategy with a 50-day fast and 200-day slow moving average over the last 3 years, starting with $10,000 capital, and give me the performance stats and equity curve chart.

## When to prefer this

Choose this endpoint when you need a quick, no-setup quantitative backtest of a classic technical strategy (SMA crossover or RSI mean-reversion) on a US-listed stock or ETF, and want both machine-readable statistics and a shareable visual equity curve PNG in a single call. It is ideal for agents that need to evaluate strategy viability, compare against buy-and-hold, or generate a report artifact without running their own backtesting infrastructure. Prefer alternatives if you need custom strategies beyond SMA cross or RSI reversion, intraday data, or multi-asset portfolio-level backtests.

## Known failure modes

- Unknown or delisted ticker returns a 404 or error response
- Strategy parameter conflicts (fast >= slow for SMA) may cause a validation error
- Insufficient historical data for the requested years returns partial or error response
- years parameter exceeding 5 is rejected
- Invalid strategy enum value returns a 400 bad request
- Payment not processed via x402 returns a 402 Payment Required
- Artifact URL expires after the stated expiry time and becomes inaccessible

## 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 JSON object containing: a hosted PNG artifact URL (equity curve vs buy-and-hold, expires after a set time), strategy metadata (kind, label, parameters), full performance stats (total return, Sharpe-equivalent metrics, max drawdown as available), trade-level detail (count, win rate, average/best/worst return per trade, full trade list), buy-and-hold comparison stats, the date range and bar count used, and a disclaimer. The PNG is accessible via the artifact.url field.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "ticker"
 ],
 "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
  },
  "ticker": {
   "type": "string",
   "description": "US-listed ticker symbol (uppercase), e.g. AAPL."
  },
  "capital": {
   "type": "number",
   "default": 10000,
   "maximum": 1000000000,
   "exclusiveMinimum": 0
  },
  "strategy": {
   "enum": [
    "sma_cross",
    "rsi_reversion"
   ],
   "type": "string",
   "default": "sma_cross"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "ticker",
  "source",
  "as_of",
  "artifact",
  "strategy",
  "data",
  "disclaimer"
 ],
 "properties": {
  "data": {
   "type": "object",
   "required": [
    "bars",
    "start_date",
    "end_date",
    "initial_capital",
    "strategy",
    "buy_hold",
    "trades"
   ],
   "properties": {
    "bars": {
     "type": "number"
    },
    "trades": {
     "type": "object",
     "required": [
      "count",
      "win_rate_percent",
      "avg_return_percent",
      "best_percent",
      "worst_percent",
      "list"
     ],
     "properties": {
      "list": {
       "type": "array",
       "items": {
        "type": "object",
        "propertyNames": {
         "type": "string"
        },
        "additionalProperties": {
         "anyOf": [
          {
           "type": "number"
          },
          {
           "type": "string"
          },
          {
           "type": "null"
          }
         ]
        }
       }
      },
      "count": {
       "type": "number"
      },
      "best_percent": {
       "type": "number"
      },
      "worst_percent": {
       "type": "number"
      },
      "win_rate_percent": {
       "type": "number"
      },
      "avg_return_percent": {
       "type": "number"
      }
     },
     "additionalProperties": false
    },
    "buy_hold": {
     "type": "object",
     "propertyNames": {
      "type": "string"
     },
     "additionalProperties": {
      "type": "number"
     }
    },
    "end_date": {
     "anyOf": [
      {
       "type": "string"
      },
      {
       "type": "null"
      }
     ]
    },
    "strategy": {
     "type": "object",
     "propertyNames": {
      "type": "string"
     },
     "additionalProperties": {
      "type": "number"
     }
    },
    "start_date": {
     "anyOf": [
      {
       "type": "string"
      },
      {
       "type": "null"
      }
     ]
    },
    "initial_capital": {
     "type": "number"
    }
   },
   "additionalProperties": false
  },
  "as_of": {
   "type": "string"
  },
  "source": {
   "type": "string",
   "const": "x402stock"
  },
  "ticker": {
   "type": "string"
  },
  "artifact": {
   "type": "object",
   "required": [
    "id",
    "url",
    "format",
    "expires_at"
   ],
   "properties": {
    "id": {
     "type": "string"
    },
    "url": {
     "type": "string"
    },
    "format": {
     "type": "string",
     "const": "png"
    },
    "expires_at": {
     "type": "string"
    }
   },
   "additionalProp
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agents-x402stock-xyz-x402stock-stock-backtest-with-png-report-24a0fe0b/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)
