{"uid":"cap_ghdzzFMYzGZieYEidWeem","slug":"position-pnl-calculator-46119aeb","name":"Position PnL Calculator","description":"Realized PnL, ROI %, and break-even for a position from entry, exit, size, side, leverage and taker/maker fee rate.","url":"https://api.24klabs.ai/api/v1/position-pnl-calculator","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"side":{"type":"string"},"size":{"type":"number"},"fee_rate":{"type":"number"},"leverage":{"type":"number"},"exit_price":{"type":"number"},"entry_price":{"type":"number"}}},"responseSchema":{"type":"json","example":{"net_pnl":198.9,"roi_pct":98.9,"gross_pnl":200}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.003","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.003/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_VtvS6BY9xVHWGvgDKuzUT","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.003","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calculates realized profit/loss, ROI percentage, and break-even price for a trading position given entry/exit prices, size, side, leverage, and fee rates.","exampleAgentPrompt":"Calculate my realized PnL, ROI, and break-even price for a long position: I entered at $42,000 and exited at $45,500, size 0.5 BTC, 10x leverage, with a 0.04% taker fee and 0.02% maker fee.","exampleUseCases":[{"title":"Crypto futures trade performance review","prompt":"I closed a long BTC futures trade — entered at $30,000, exited at $34,200, position size 1 BTC, 5x leverage, taker fee 0.04% and maker fee 0.02%. What's my realized PnL, ROI, and break-even price?"},{"title":"Short position loss assessment","prompt":"I was short ETH from $2,100 and got stopped out at $2,350, size 10 ETH, 3x leverage, taker fee 0.06% both ways. How much did I lose and what was the break-even price I needed to hit?"},{"title":"Leveraged trade profitability check before closing","prompt":"If I close my long position now — I entered at $0.85, current price is $1.10, size 5000 tokens, 20x leverage, 0.04% taker fee — what will my realized PnL and ROI be?"}],"resultDescription":"Returns the realized PnL in dollar terms, ROI as a percentage, and the break-even price at which the trade would have been neither profitable nor unprofitable, all accounting for the specified leverage and fee rates.","failureModes":["Missing required fields (entry price, exit price, size, side, leverage) return a 400 validation error","Invalid side value (not long/short) returns an error","Zero or negative leverage causes a computation error","Fee rates out of expected range may produce warnings or errors","Insufficient USDC balance for the $0.003 per-call fee results in a payment failure"],"whenToPreferThis":"Use this endpoint when you need a precise, fee-aware PnL calculation for a single closed or hypothetical position on any leveraged instrument — especially when taker/maker fee differentiation and leverage-adjusted ROI matter. Prefer this over manual calculations or generic spreadsheet formulas when integrating into an automated trading analysis or agent workflow.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T18:34:08.003Z","isFirstParty":false}