# SperaxOS DeFi Strategy Backtesting API

> SperaxOS DeFi Strategy Backtesting API is a paid API for AI agents from chat.sperax.io, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-03).

Runs historical backtests of DeFi investment strategies (yield farming, DCA, rebalancing, static hold) on specified protocols and chains, returning simulated performance metrics over a given date range.

## Facts

- Endpoint: POST https://chat.sperax.io/api/x402/tools/backtesting/runBacktest?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-03
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/speraxos-defi-strategy-backtesting-api-736d7848
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_4WejGXrPOH09Nkj2DiaAF

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 speraxos-defi-strategy-backtesting-api-736d7848 -d '<json body>'
```

Example prompt: Backtest a yield farming strategy on Aave V3 on Ethereum starting January 1 2023 through December 31 2023 with $10,000 initial capital and reinvest earnings turned on — what would my returns have been?

## When to prefer this

Choose this endpoint when you need historical simulation of DeFi strategies on specific protocols like Aave, Curve, or Yearn Finance. Ideal for comparing yield farming vs holding vs DCA strategies with real historical on-chain data. Pay-per-use via USDC x402 means no API key setup required — best for agents or users who need occasional on-demand backtesting without a subscription.

## Known failure modes

- Protocol name not recognized or misspelled — returns error indicating invalid protocol
- Date range exceeds 2-year maximum — returns validation error
- Chain ID not supported for the specified protocol — returns incompatibility error
- Target token CoinGecko ID not found for DCA strategy — returns token lookup error
- Start date after end date — returns date range validation error
- Payment failure via x402 — returns 402 Payment Required if USDC payment not settled

## How this service works

AI-powered DeFi intelligence APIs payable via the x402 HTTP payment protocol. No API key required — pay per request with USDC on Base. Identity-only (SIWX) endpoints are free for wallets with an agentcash identity.

## Output

Returns simulated backtest results for the specified DeFi strategy, including historical portfolio performance, total returns, yield earned, and period-over-period metrics based on real historical protocol data over the specified date range and initial capital.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "chainId": {
   "type": "number",
   "description": "Chain ID (e.g. 1 for Ethereum, 42161 for Arbitrum)."
  },
  "endDate": {
   "type": "string",
   "description": "End date in ISO format (YYYY-MM-DD). Defaults to today. Max 2 years of history."
  },
  "protocol": {
   "type": "string",
   "description": "Protocol name to backtest (e.g. 'Aave V3', 'Curve Finance', 'Yearn Finance')."
  },
  "strategy": {
   "enum": [
    "yield_farming",
    "dca",
    "yield_rebalancing",
    "static_hold"
   ],
   "type": "string",
   "description": "Strategy type: 'yield_farming' (deploy into protocol and collect yield), 'dca' (dollar-cost average into a token), 'yield_rebalancing' (yield farm with periodic rebalancing), 'static_hold' (buy and hold token)."
  },
  "startDate": {
   "type": "string",
   "description": "Start date in ISO format (YYYY-MM-DD). Maximum 2 years in the past."
  },
  "targetToken": {
   "type": "string",
   "description": "For DCA strategy: the CoinGecko token ID to accumulate (e.g. 'ethereum', 'bitcoin')."
  },
  "dcaFrequency": {
   "enum": [
    "daily",
    "weekly",
    "monthly"
   ],
   "type": "string",
   "description": "For DCA strategy: how often to buy. One of 'daily', 'weekly', 'monthly'."
  },
  "initialCapital": {
   "type": "number",
   "description": "Initial capital in USD (e.g. 10000)."
  },
  "reinvestEarnings": {
   "type": "boolean",
   "description": "Whether to compound (reinvest) earnings daily. Default: true."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/speraxos-defi-strategy-backtesting-api-736d7848/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from chat.sperax.io](https://www.zero.xyz/host/chat.sperax.io/llms.txt)
