# FinMath for Agents

> FinMath for Agents is a paid API for AI agents from x402-finmath.whale-feed-max.workers.dev, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-15).

Computes financial math for trading agents: position sizing, liquidation price, DCA schedules, fees, slippage cost, and APY — paid per-call via USDC on Base.

## Facts

- Endpoint: POST https://x402-finmath.whale-feed-max.workers.dev/v1/calc
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/finmath-for-agents-c9f8dbd9
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_zJnd7AFjyIsOGydxaJJNT

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-for-agents-c9f8dbd9 -d '<json body>'
```

Example prompt: I have $10,000 in equity and want to risk 1.5% per trade with a 3% stop-loss — what position size should I use?

## When to prefer this

Choose this endpoint when an AI trading agent needs fast, deterministic financial math computed server-side without managing spreadsheet logic locally. It is ideal for agents that need position sizing, liquidation prices, or DCA slot sizing in real-time during trade execution flows, and prefer pay-per-call USDC billing with no API key management. Prefer alternatives if you need market data, price feeds, or order execution — this is purely a math utility.

## Known failure modes

- Missing required parameters for the selected calculation type returns an error or null fields
- Invalid or zero values for denominator fields (e.g. slPct=0) may cause divide-by-zero errors
- Payment failure via x402/USDC prevents the call from completing
- Passing parameters for the wrong calculation type (e.g. APY params to a position sizing call) returns irrelevant or empty results
- Network timeout on the Cloudflare Worker edge node

## How this service works

Pay-per-call financial math utilities for AI trading agents: position sizing, liquidation, DCA, fees, slippage, APY. Payment via x402, USDC on Base. No API keys, no accounts.

## Output

Returns a flat JSON object with whichever computed fields apply to the requested calculation: positionSize (units to trade), riskAmount (dollar risk), liquidationLong (liquidation price for longs), perSlot and totalCost (DCA breakdown), fee and net (fee-adjusted amounts), slippageCost (slippage in dollar terms), and apyPct (annualized yield). Unused fields are omitted.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "apr": {
   "type": "number",
   "description": "APR, % (apy)"
  },
  "entry": {
   "type": "number",
   "description": "Entry price (liq)"
  },
  "price": {
   "type": "number",
   "description": "Asset price (slippage)"
  },
  "slPct": {
   "type": "number",
   "description": "Stop-loss, % (position)"
  },
  "slots": {
   "type": "number",
   "description": "Number of DCA slots (dca)"
  },
  "total": {
   "type": "number",
   "description": "Total amount to invest (dca)"
  },
  "amount": {
   "type": "number",
   "description": "Trade amount (fees, slippage)"
  },
  "equity": {
   "type": "number",
   "description": "Account equity (position)"
  },
  "feePct": {
   "type": "number",
   "description": "Fee, % (fees)"
  },
  "margin": {
   "type": "number",
   "description": "Margin (liq, optional)"
  },
  "riskPct": {
   "type": "number",
   "description": "Risk, % of equity (position)"
  },
  "slipPct": {
   "type": "number",
   "description": "Slippage, % (slippage)"
  },
  "leverage": {
   "type": "number",
   "description": "Leverage (liq)"
  },
  "compoundPerYear": {
   "type": "number",
   "description": "Compounds per year (apy)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "fee": {
   "type": "number"
  },
  "net": {
   "type": "number"
  },
  "apyPct": {
   "type": "number"
  },
  "perSlot": {
   "type": "number"
  },
  "totalCost": {
   "type": "number"
  },
  "riskAmount": {
   "type": "number"
  },
  "positionSize": {
   "type": "number"
  },
  "slippageCost": {
   "type": "number"
  },
  "liquidationLong": {
   "type": "number"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/finmath-for-agents-c9f8dbd9/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-finmath.whale-feed-max.workers.dev](https://www.zero.xyz/host/x402-finmath.whale-feed-max.workers.dev/llms.txt)
