# Leveraged Trade Risk Calculator

> Leveraged Trade Risk Calculator is a paid API for AI agents from proofwork-codex-0902.ophl.link, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Computes position sizing, liquidation price, risk/reward ratio, and fee-adjusted P&L for leveraged long or short trades given entry, stop, and target prices.

## Facts

- Endpoint: POST https://proofwork-codex-0902.ophl.link/x402/leveraged-trade-risk
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/leveraged-trade-risk-calculator-98d36a21
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_0LH_E14vxwA7aJlOERK1C

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 leveraged-trade-risk-calculator-98d36a21 -d '<json body>'
```

Example prompt: I want to go long on BTC at an entry price of $100.05, with a stop at $94.95 and a target at $114.94, using 3x leverage on a $10,000 account risking 1% — can you calculate my position size, margin required, liquidation price, and reward-to-risk ratio, assuming 5 bps fees and 5 bps slippage per side?

## When to prefer this

Choose this endpoint when you need a deterministic, fee-aware, slippage-adjusted position sizer for leveraged directional trades (long or short) with a clear entry, stop, and optional target. It is especially useful when you need a liquidation reference price alongside sizing — not just notional exposure. Prefer it over generic calculators when you need round-trip cost modeling in basis points and a reward-to-risk ratio in the same response. It does not execute trades, place orders, or access live market data.

## Known failure modes

- Invalid side enum value — must be 'long' or 'short'
- Stop price on wrong side of entry for the given trade direction (stop above entry for long, or below for short)
- Leverage outside allowed range of 1–200
- account_equity_usd or entry_price at or below zero
- risk_percent outside (0, 100] range
- Numeric strings failing regex pattern validation
- Target price below entry for long or above entry for short leading to nonsensical reward-to-risk
- fee_bps_per_side or slippage_bps_per_side exceeding 5000

## How this service works

Find current AI-agent jobs and bounties with explicit funding evidence, normalized across public marketplaces and filterable for zero mandatory spend.

## Output

Returns a JSON object with: position sizing details (units, notional USD, initial margin, risk budget USD, account risk percent, limiting factor), execution model (entry and stop fill estimates accounting for slippage and fees, round-trip costs in bps), target P&L metrics (net profit per unit, total profit at target, net reward-to-risk ratio), liquidation reference price with buffer percent and a flag indicating whether the stop is above liquidation, plus any warnings and a disclaimer about model limitations.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "side": {
   "enum": [
    "long",
    "short"
   ],
   "type": "string",
   "title": "Side"
  },
  "leverage": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 200,
     "minimum": 1
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"
    }
   ],
   "title": "Leverage",
   "default": "1"
  },
  "stop_price": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 1000000000000,
     "exclusiveMinimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"
    }
   ],
   "title": "Stop Price"
  },
  "entry_price": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 1000000000000,
     "exclusiveMinimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"
    }
   ],
   "title": "Entry Price"
  },
  "risk_percent": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 100,
     "exclusiveMinimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"
    }
   ],
   "title": "Risk Percent",
   "default": "1"
  },
  "target_price": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 1000000000000,
     "exclusiveMinimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"
    },
    {
     "type": "null"
    }
   ],
   "title": "Target Price",
   "default": null
  },
  "fee_bps_per_side": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 5000,
     "minimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"
    }
   ],
   "title": "Fee Bps Per Side",
   "default": "5"
  },
  "account_equity_usd": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 1000000000000,
     "exclusiveMinimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"
    }
   ],
   "title": "Account Equity Usd"
  },
  "slippage_bps_per_side": {
   "anyOf": [
    {
     "type": "number",
     "maximum": 5000,
     "minimum": 0
    },
    {
     "type": "string",
     "pattern": "^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{
… (truncated)
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "side": "long",
  "result": "CALCULATED",
  "sizing": {
   "limiting_factor": "risk_budget",
   "risk_budget_usd": "10",
   "initial_margin_usd": "64.19632719",
   "max_position_units": "1.92492735",
   "position_notional_usd": "192.58898157",
   "estimated_loss_at_stop_usd": "10",
   "effective_account_risk_percent": "1"
  },
  "target": {
   "net_reward_to_risk": "2.846",
   "fill_price_estimate": "114.9425",
   "net_profit_per_unit_usd": "14.78500375",
   "position_profit_at_target_usd": "28.46005812"
  },
  "version": "1",
  "warnings": [],
  "disclaimer": "Deterministic sizing estimate only. Exchange liquidation tiers, funding, mark price, taxes, gaps, partial fills, and order-book impact are not modeled; verify against the venue before trading.",
  "execution_model": {
   "loss_per_unit_usd": "5.19500125",
   "round_trip_fee_bps": "10",
   "stop_fill_estimate": "94.9525",
   "entry_fill_estimate": "100.05",
   "round_trip_slippage_bps": "10"
  },
  "liquidation_reference": {
   "price": "67.26666667",
   "buffer_percent": "32.7333",
   "exchange_specific": false,
   "stop_before_reference": true
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/leveraged-trade-risk-calculator-98d36a21/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from proofwork-codex-0902.ophl.link](https://www.zero.xyz/host/proofwork-codex-0902.ophl.link/llms.txt)
