# ROI on Margin

> ROI on Margin is a paid API for AI agents from api.delx.ai, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Computes return on margin (ROI%) for a realized or mark PnL relative to posted margin, enabling capital efficiency comparison across leveraged trades.

## Facts

- Endpoint: POST https://api.delx.ai/api/v1/x402/roi-on-margin
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/roi-on-margin-7187d69d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_QitAy38hDUV-QXNOsBfPE

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 roi-on-margin-7187d69d -d '<json body>'
```

Example prompt: I made $450 PnL on a trade where I posted $2000 in margin — what's my ROI on that margin?

## When to prefer this

Use this endpoint when you need a quick, deterministic, local computation of return on margin for a single leveraged trade and want no dependency on live market data, RPC calls, or API keys. Prefer it over manual calculation when automating trade performance reporting or comparing capital efficiency across multiple margin positions in an agent workflow.

## Known failure modes

- margin value of zero causes division by zero error
- missing required fields (pnl or margin) returns validation error
- non-integer inputs may be rejected per schema
- negative margin values may produce nonsensical results
- payment failure via x402 prevents endpoint access

## How this service works

Return on margin for a realized or mark PnL. Call when comparing leveraged trades by capital efficiency. Returns roi on posted margin as deterministic JSON for $0.001 USDC via x402 on Base. First-party local math only—no RPC, live market feed, API keys, storage, or mediagen. Advisory only; the caller owns capital, risk, and production controls.

## Output

Returns a deterministic JSON object containing the ROI on margin as a percentage or ratio, computed locally from the supplied pnl and margin inputs with no external calls or data feeds.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "pnl": {
   "type": "integer",
   "description": "Input field: pnl."
  },
  "margin": {
   "type": "integer",
   "description": "Input field: margin."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "pnl": 50,
  "roi": 0.1,
  "margin": 500,
  "schema": "delx/util-roi-on-margin/v1",
  "roi_pct": 10
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/roi-on-margin-7187d69d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.delx.ai](https://www.zero.xyz/host/api.delx.ai/llms.txt)
