# finmath DCA Backtest

> finmath DCA Backtest is a paid API for AI agents from finmath.qzqh5rrbkz.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-16).

Backtests a dollar-cost averaging (DCA) strategy against a historical price series, computing exact portfolio metrics using deterministic arithmetic

## Facts

- Endpoint: POST https://finmath.qzqh5rrbkz.workers.dev/v1/dca_backtest
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-16
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/finmath-dca-backtest-bd3a31a6
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_6-jKvdaJfftg6kIa-jsBo

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 finmath-dca-backtest-bd3a31a6 -d '<json body>'
```

Example prompt: Run a DCA backtest for me — here are the weekly closing prices for ETH over the past year: [1800, 1750, 1900, 2100, 1950, 2200, 2400, 2300, 2500, 2450, 2600, 2700, 2650, 2800, 2750, 2900, 3000, 2950, 3100, 3050, 3200, 3150, 3300, 3250, 3400, 3350, 3500, 3450, 3600, 3550, 3700, 3650, 3800, 3750, 3900, 3850, 4000, 3950, 4100, 4050, 4200, 4150, 4300, 4250, 4400, 4350, 4500, 4450, 4600, 4550, 4700] — and assume I put in $200 each period.

## When to prefer this

Use this endpoint when you need exact, deterministic DCA backtest calculations rather than relying on LLM arithmetic, which is error-prone for iterative financial computations. Prefer this over manual calculation when you have a historical price series and want precise average cost basis, total return, and unit accumulation figures for a fixed periodic contribution strategy.

## Known failure modes

- Missing required 'prices' array — returns 400 error
- Missing required 'contribution' amount — returns 400 error
- Empty prices array — may return zero or error
- Non-numeric values in prices array — validation error
- Payment not provided or insufficient USDC — 402 Payment Required
- Contribution value of zero or negative — may return error or degenerate result

## How this service works

Deterministic finance and crypto math for AI agents: TradFi (NPV, IRR, XIRR, Black-Scholes + Greeks, bonds, VaR, Sharpe) and DeFi (impermanent loss, perp liquidation, funding, Uniswap v3, health factor, cost basis). Exact, model-free arithmetic that LLMs get wrong — priced per call in USDC.

## Output

Returns a result object with DCA portfolio metrics computed from the price series and fixed contribution, including total invested, total portfolio value, number of units accumulated, average cost basis, total return, and possibly period-by-period breakdown; plus a meta object with request metadata.

## Example request

```json
{
 "prices": [
  100,
  102,
  98,
  105,
  103,
  107,
  104,
  106
 ],
 "contribution": 500
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "prices",
  "contribution"
 ],
 "properties": {
  "prices": {
   "type": "array",
   "description": "prices"
  },
  "contribution": {
   "type": "number",
   "description": "contribution"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "result",
  "meta"
 ],
 "properties": {
  "meta": {
   "type": "object"
  },
  "result": {}
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/finmath-dca-backtest-bd3a31a6/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from finmath.qzqh5rrbkz.workers.dev](https://www.zero.xyz/host/finmath.qzqh5rrbkz.workers.dev/llms.txt)
