{
  "format": "delx/discovery-pack/v1",
  "id": "trade-risk-desk",
  "title": "Trade risk desk math for agents",
  "description": "Desk-ready local calc for crypto trade agents: PnL, fees, slippage, liquidation, Kelly, VWAP/TWAP, and position sizing—$0.001 x402, no exchange keys or market feed.",
  "audience": "Trading, quant, and risk agents",
  "query": "pnl kelly slippage liquidation margin position size trading math for agents",
  "keywords": [
    "PnL API for agents",
    "Kelly criterion API",
    "liquidation price calculator",
    "slippage bps API",
    "position size by risk",
    "VWAP TWAP API",
    "x402 trading math",
    "trade risk desk"
  ],
  "updated_at": "2026-08-23",
  "canonical_url": "https://commerce.delx.ai/packs/trade-risk-desk",
  "machine_url": "https://commerce.delx.ai/packs/trade-risk-desk.json",
  "entrypoints": {
    "human": "https://commerce.delx.ai/?q=pnl%20kelly%20slippage%20liquidation%20margin%20position%20size%20trading%20math%20for%20agents",
    "intent_search": "https://api.delx.ai/api/v1/x402/start?q=pnl%20kelly%20slippage%20liquidation%20margin%20position%20size%20trading%20math%20for%20agents",
    "graph": "https://commerce.delx.ai/discovery.json"
  },
  "attribution": {
    "header": "x-delx-source",
    "value": "discovery-pack-trade-risk-desk"
  },
  "products": [
    {
      "tool_name": "util_pnl_pct",
      "service_name": "Percent PnL",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/pnl-pct",
      "product_url": "https://commerce.delx.ai/products/util-pnl-pct",
      "intent_url": "https://commerce.delx.ai/intents/pnl-pct-api",
      "machine_url": "https://commerce.delx.ai/intents/pnl-pct-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "entry": {
            "description": "Input field: entry.",
            "type": "integer"
          },
          "exit": {
            "description": "Input field: exit.",
            "type": "integer"
          }
        },
        "required": [
          "entry",
          "exit"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "entry": 100,
        "exit": 110
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/pnl-pct -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"entry\":100,\"exit\":110}'"
    },
    {
      "tool_name": "util_pnl_with_fees",
      "service_name": "PnL After Fees",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/pnl-with-fees",
      "product_url": "https://commerce.delx.ai/products/util-pnl-with-fees",
      "intent_url": "https://commerce.delx.ai/intents/pnl-with-fees-api",
      "machine_url": "https://commerce.delx.ai/intents/pnl-with-fees-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "entry": {
            "description": "Input field: entry.",
            "type": "integer"
          },
          "exit": {
            "description": "Input field: exit.",
            "type": "integer"
          },
          "size": {
            "description": "Input field: size.",
            "type": "integer"
          },
          "fee_rate": {
            "description": "Input field: fee rate.",
            "type": "number"
          }
        },
        "required": [
          "entry",
          "exit",
          "size",
          "fee_rate"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "entry": 100,
        "exit": 110,
        "size": 1,
        "fee_rate": 0.001
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/pnl-with-fees -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"entry\":100,\"exit\":110,\"size\":1,\"fee_rate\":0.001}'"
    },
    {
      "tool_name": "util_unrealized_pnl",
      "service_name": "Unrealized PnL",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/unrealized-pnl",
      "product_url": "https://commerce.delx.ai/products/util-unrealized-pnl",
      "intent_url": "https://commerce.delx.ai/intents/unrealized-pnl-api",
      "machine_url": "https://commerce.delx.ai/intents/unrealized-pnl-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "entry": {
            "description": "Input field: entry.",
            "type": "integer"
          },
          "mark": {
            "description": "Input field: mark.",
            "type": "integer"
          },
          "size": {
            "description": "Input field: size.",
            "type": "integer"
          }
        },
        "required": [
          "entry",
          "mark",
          "size"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "entry": 100,
        "mark": 95,
        "size": 3
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/unrealized-pnl -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"entry\":100,\"mark\":95,\"size\":3}'"
    },
    {
      "tool_name": "util_slippage_bps",
      "service_name": "Slippage Basis Points",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/slippage-bps",
      "product_url": "https://commerce.delx.ai/products/util-slippage-bps",
      "intent_url": "https://commerce.delx.ai/intents/slippage-bps-api",
      "machine_url": "https://commerce.delx.ai/intents/slippage-bps-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "mid": {
            "description": "Input field: mid.",
            "type": "integer"
          },
          "fill": {
            "description": "Input field: fill.",
            "type": "number"
          }
        },
        "required": [
          "mid",
          "fill"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "mid": 100,
        "fill": 100.3
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/slippage-bps -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"mid\":100,\"fill\":100.3}'"
    },
    {
      "tool_name": "util_liq_price_long",
      "service_name": "Long Liquidation Price",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/liq-price-long",
      "product_url": "https://commerce.delx.ai/products/util-liq-price-long",
      "intent_url": "https://commerce.delx.ai/intents/liq-price-long-api",
      "machine_url": "https://commerce.delx.ai/intents/liq-price-long-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "entry": {
            "description": "Input field: entry.",
            "type": "integer"
          },
          "leverage": {
            "description": "Input field: leverage.",
            "type": "integer"
          },
          "mmr": {
            "description": "Input field: mmr.",
            "type": "number"
          }
        },
        "required": [
          "entry",
          "leverage",
          "mmr"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "entry": 100,
        "leverage": 10,
        "mmr": 0.005
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/liq-price-long -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"entry\":100,\"leverage\":10,\"mmr\":0.005}'"
    },
    {
      "tool_name": "util_liq_price_short",
      "service_name": "Short Liquidation Price",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/liq-price-short",
      "product_url": "https://commerce.delx.ai/products/util-liq-price-short",
      "intent_url": "https://commerce.delx.ai/intents/liq-price-short-api",
      "machine_url": "https://commerce.delx.ai/intents/liq-price-short-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "entry": {
            "description": "Input field: entry.",
            "type": "integer"
          },
          "leverage": {
            "description": "Input field: leverage.",
            "type": "integer"
          },
          "mmr": {
            "description": "Input field: mmr.",
            "type": "number"
          }
        },
        "required": [
          "entry",
          "leverage",
          "mmr"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "entry": 100,
        "leverage": 10,
        "mmr": 0.005
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/liq-price-short -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"entry\":100,\"leverage\":10,\"mmr\":0.005}'"
    },
    {
      "tool_name": "util_position_size_risk",
      "service_name": "Position Size by Risk",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/position-size-risk",
      "product_url": "https://commerce.delx.ai/products/util-position-size-risk",
      "intent_url": "https://commerce.delx.ai/intents/position-size-risk-api",
      "machine_url": "https://commerce.delx.ai/intents/position-size-risk-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "equity": {
            "description": "Input field: equity.",
            "type": "integer"
          },
          "risk_pct": {
            "description": "Input field: risk pct.",
            "type": "number"
          },
          "entry": {
            "description": "Input field: entry.",
            "type": "integer"
          },
          "stop": {
            "description": "Input field: stop.",
            "type": "integer"
          }
        },
        "required": [
          "equity",
          "risk_pct",
          "entry",
          "stop"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "equity": 10000,
        "risk_pct": 0.01,
        "entry": 100,
        "stop": 95
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/position-size-risk -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"equity\":10000,\"risk_pct\":0.01,\"entry\":100,\"stop\":95}'"
    },
    {
      "tool_name": "util_kelly_fraction",
      "service_name": "Kelly Fraction",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/kelly-fraction",
      "product_url": "https://commerce.delx.ai/products/util-kelly-fraction",
      "intent_url": "https://commerce.delx.ai/intents/kelly-fraction-api",
      "machine_url": "https://commerce.delx.ai/intents/kelly-fraction-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "win_prob": {
            "description": "Input field: win prob.",
            "type": "number"
          },
          "b": {
            "description": "Input field: b.",
            "type": "number"
          }
        },
        "required": [
          "win_prob",
          "b"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "win_prob": 0.55,
        "b": 1.2
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/kelly-fraction -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"win_prob\":0.55,\"b\":1.2}'"
    },
    {
      "tool_name": "util_half_kelly",
      "service_name": "Half-Kelly Fraction",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/half-kelly",
      "product_url": "https://commerce.delx.ai/products/util-half-kelly",
      "intent_url": "https://commerce.delx.ai/intents/half-kelly-api",
      "machine_url": "https://commerce.delx.ai/intents/half-kelly-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "win_prob": {
            "description": "Input field: win prob.",
            "type": "number"
          },
          "b": {
            "description": "Input field: b.",
            "type": "number"
          }
        },
        "required": [
          "win_prob",
          "b"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "win_prob": 0.55,
        "b": 1.2
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/half-kelly -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"win_prob\":0.55,\"b\":1.2}'"
    },
    {
      "tool_name": "util_vwap_simple",
      "service_name": "Simple VWAP",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/vwap-simple",
      "product_url": "https://commerce.delx.ai/products/util-vwap-simple",
      "intent_url": "https://commerce.delx.ai/intents/vwap-simple-api",
      "machine_url": "https://commerce.delx.ai/intents/vwap-simple-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "samples": {
            "description": "Input field: samples.",
            "type": "array"
          }
        },
        "required": [
          "samples"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "samples": [
          {
            "price": 10,
            "size": 2
          },
          {
            "price": 12,
            "size": 2
          }
        ]
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/vwap-simple -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"samples\":[{\"price\":10,\"size\":2},{\"price\":12,\"size\":2}]}'"
    },
    {
      "tool_name": "util_drawdown_pct",
      "service_name": "Drawdown Percent",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/drawdown-pct",
      "product_url": "https://commerce.delx.ai/products/util-drawdown-pct",
      "intent_url": "https://commerce.delx.ai/intents/drawdown-pct-api",
      "machine_url": "https://commerce.delx.ai/intents/drawdown-pct-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "peak": {
            "description": "Input field: peak.",
            "type": "integer"
          },
          "trough": {
            "description": "Input field: trough.",
            "type": "integer"
          }
        },
        "required": [
          "peak",
          "trough"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "peak": 120,
        "trough": 90
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/drawdown-pct -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"peak\":120,\"trough\":90}'"
    },
    {
      "tool_name": "util_amm_price_impact_bps",
      "service_name": "AMM Price Impact (bps)",
      "category": "commercial-operations",
      "price_usdc": "0.001",
      "method": "POST",
      "route": "/api/v1/x402/amm-price-impact-bps",
      "product_url": "https://commerce.delx.ai/products/util-amm-price-impact-bps",
      "intent_url": "https://commerce.delx.ai/intents/amm-price-impact-bps-api",
      "machine_url": "https://commerce.delx.ai/intents/amm-price-impact-bps-api.json",
      "input_schema": {
        "type": "object",
        "properties": {
          "reserve_in": {
            "description": "Input field: reserve in.",
            "type": "integer"
          },
          "reserve_out": {
            "description": "Input field: reserve out.",
            "type": "integer"
          },
          "amount_in": {
            "description": "Input field: amount in.",
            "type": "integer"
          },
          "fee_bps": {
            "description": "Input field: fee bps.",
            "type": "integer"
          }
        },
        "required": [
          "reserve_in",
          "reserve_out",
          "amount_in",
          "fee_bps"
        ],
        "additionalProperties": true
      },
      "example_input": {
        "reserve_in": 1000,
        "reserve_out": 1000,
        "amount_in": 50,
        "fee_bps": 30
      },
      "agentcash_buy": "npx agentcash@latest fetch https://api.delx.ai/api/v1/x402/amm-price-impact-bps -m POST -H 'x-delx-source: discovery-pack-trade-risk-desk' --max-amount 0.001 -b '{\"reserve_in\":1000,\"reserve_out\":1000,\"amount_in\":50,\"fee_bps\":30}'"
    }
  ]
}
