{"uid":"cap_JlwUSD1gO8TPOjy7PqTdZ","slug":"position-pnl-calculator-0962e16e","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/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_dZL2OqZAIXD20-Q_w2T3d","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 PnL, ROI percentage, and break-even price for a trading position given entry/exit prices, size, side, leverage, and fee rates.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Crypto futures trade review","prompt":"I shorted ETH with a position size of 5 ETH, entered at $3,200 and closed at $2,900 using 5x leverage with a 0.04% taker fee — what was my realized PnL and ROI?"},{"title":"Break-even planning before exit","prompt":"I'm long on SOL with 2 SOL at an entry price of $150, using 3x leverage and a 0.02% maker fee — what exit price do I need to break even?"},{"title":"Post-trade fee impact analysis","prompt":"Compare my net PnL on a long BTC trade: entry $58,000, exit $62,000, size 0.5 BTC, 1x leverage — calculate once with a 0.04% taker fee and once with a 0.02% maker fee."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T19:02:31.639Z","isFirstParty":false}