# Position PnL Calculator

> Position PnL Calculator is a paid API for AI agents from api.24klabs.ai, paid per call via x402, $0.003/call, status unknown (last checked 2026-09-13).

Calculates realized PnL, ROI percentage, and break-even price for a trading position given entry/exit prices, size, side, leverage, and fee rates.

## Facts

- Endpoint: POST https://api.24klabs.ai/api/position-pnl-calculator
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/position-pnl-calculator-0962e16e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_JlwUSD1gO8TPOjy7PqTdZ

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 position-pnl-calculator-0962e16e -d '<json body>'
```

Example prompt: I went long on BTC with a position size of 1.0 BTC, entered at $60,000 and exited at $65,000 using 10x leverage — can you calculate my realized PnL, ROI, and break-even price assuming a 0.04% taker fee?

## When to prefer this

Choose this endpoint when you need a precise, fee-adjusted PnL and ROI calculation for a single closed trading position, especially for leveraged derivatives or futures trades. It is ideal when break-even analysis matters or when you need to distinguish between taker and maker fee impacts on net profit.

## Known failure modes

- Missing required fields (entry, exit, size, side) returns a 400 validation error
- Invalid side value (not long/short) causes a parameter error
- Zero or negative leverage causes a computation error
- Fee rate out of acceptable range returns a validation failure
- Network timeout or server error returns a 5xx response

## How this service works

Realized PnL, ROI %, and break-even for a position from entry, exit, size, side, leverage and taker/maker fee rate.

## Output

Returns realized PnL in quote currency, ROI as a percentage, and the break-even exit price — all accounting for entry/exit prices, position size, direction (long/short), leverage multiplier, and taker/maker fee rates.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "side": {
   "type": "string"
  },
  "size": {
   "type": "number"
  },
  "fee_rate": {
   "type": "number"
  },
  "leverage": {
   "type": "number"
  },
  "exit_price": {
   "type": "number"
  },
  "entry_price": {
   "type": "number"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "net_pnl": 198.9,
  "roi_pct": 98.9,
  "gross_pnl": 200
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/position-pnl-calculator-0962e16e/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.24klabs.ai](https://www.zero.xyz/host/api.24klabs.ai/llms.txt)
