# Realized PnL (FIFO Lite)

> Realized PnL (FIFO Lite) 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).

Calculates FIFO-style realized profit and loss from sequential buy/sell fills using local deterministic math, returning a PnL summary as JSON.

## Facts

- Endpoint: POST https://api.delx.ai/api/v1/x402/realized-pnl-fifo
- 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/realized-pnl-fifo-lite-17416951
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__HS8OSuuUEG7G35tfZXF5

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 realized-pnl-fifo-lite-17416951 -d '<json body>'
```

Example prompt: Calculate the realized PnL using FIFO on a position where I entered at 42000, exited at 43500, and closed 3 contracts.

## When to prefer this

Use this endpoint when you need a fast, deterministic, advisory FIFO realized PnL computation from raw fill data (entry price, exit price, close size) without access to a full OMS, live market feed, or external data source. Prefer this over more complex PnL services when the fill tape is simple and sequential and you do not need position tracking, multi-leg attribution, or persistent state.

## Known failure modes

- Missing required fields (entry, exit, or close_size) result in a validation error
- Non-integer values for price or size fields cause a schema rejection
- Negative or zero close_size may produce unexpected or invalid PnL results
- Payment failure via x402 results in a 402 response before computation occurs

## How this service works

Lite FIFO-style realized PnL from sequential buy/sell fills. Call when attributing closed PnL from a short fill tape without a full OMS. Returns realized pnl summary from fills 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

A deterministic JSON object summarizing realized PnL computed via FIFO logic from the provided entry price, exit price, and close size. The output is advisory only and produced entirely through local math with no external data sources or storage.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "exit": {
   "type": "integer",
   "description": "Input field: exit."
  },
  "entry": {
   "type": "integer",
   "description": "Input field: entry."
  },
  "close_size": {
   "type": "integer",
   "description": "Input field: close size."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "schema": "delx/util-realized-pnl-fifo/v1",
  "close_size": 2,
  "realized_pnl": 10
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/realized-pnl-fifo-lite-17416951/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)
