{"uid":"cap_QitAy38hDUV-QXNOsBfPE","slug":"roi-on-margin-7187d69d","name":"ROI on Margin","description":"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.","url":"https://api.delx.ai/api/v1/x402/roi-on-margin","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"pnl":{"type":"integer","description":"Input field: pnl."},"margin":{"type":"integer","description":"Input field: margin."}}},"responseSchema":{"type":"json","example":{"pnl":50,"roi":0.1,"margin":500,"schema":"delx/util-roi-on-margin/v1","roi_pct":10}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_DEhZQ4GG-mwQbs7Md0bAD","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes return on margin (ROI%) for a realized or mark PnL relative to posted margin, enabling capital efficiency comparison across leveraged trades.","exampleAgentPrompt":"I made $450 PnL on a trade where I posted $2000 in margin — what's my ROI on that margin?","exampleUseCases":[{"title":"Comparing two leveraged futures trades","prompt":"I have two trades: one made $800 PnL with $5000 margin posted, and another made $300 PnL with $1000 margin posted — which was more capital efficient by ROI on margin?"},{"title":"Evaluating a realized perp trade","prompt":"My perpetual futures trade closed with a realized PnL of $1200 and I had $4000 in margin locked up — can you calculate the ROI on margin for me?"},{"title":"Assessing mark PnL efficiency on open position","prompt":"My open position currently has a mark PnL of $550 and $3500 margin posted — what's the return on margin so far?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T07:14:45.914Z","isFirstParty":false}