{"uid":"cap_xbMCMDe2TNQbRChg__Riq","slug":"p-l-stats-calculator-59cb7efc","name":"P&L Stats Calculator","description":"Compute trade P&L statistics from caller-supplied realized P&L values: win rate, profit factor, max drawdown, and rolling-window statistics. No market data or account access -- purely a function of the numbers supplied.","url":"https://api.edifiedlab.com/v1/market/pnl-stats?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"pnls":{"type":"array","items":{"type":"number","maximum":1e+150,"minimum":-1e+150},"maxItems":5000,"minItems":1},"rolling_window":{"type":"integer","default":20,"maximum":5000,"minimum":1}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.011","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.011/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.011","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.011","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_zHzFDSck4fBrL3tI6u7Ks","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.011","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes trade P&L statistics (win rate, profit factor, max drawdown, rolling-window stats) from a caller-supplied array of realized P&L values","exampleAgentPrompt":"Calculate trading stats for these 50 realized P&L values — [12.5, -8.3, 22.1, -5.0, ...] — using a rolling window of 20, and give me the win rate, profit factor, and max drawdown.","exampleUseCases":[{"title":"Backtested strategy performance review","prompt":"I ran a backtest and have 200 trade P&L values. Can you compute the win rate, profit factor, and max drawdown for me using a 30-trade rolling window?"},{"title":"Live trading journal analytics","prompt":"Here are my realized P&Ls from last month's trades: [45, -20, 30, -15, 60, -10, 25]. What's my win rate and profit factor, and show me rolling stats with a window of 5?"},{"title":"Comparing two strategy variants","prompt":"I have two sets of trade P&Ls — strategy A has 100 values and strategy B has 100 values. Can you calculate max drawdown and profit factor for strategy A first, using a 20-trade rolling window?"}],"resultDescription":"Returns computed statistics over the supplied P&L array including win rate (fraction of positive trades), profit factor (gross profit divided by gross loss), maximum drawdown (largest peak-to-trough loss), and rolling-window versions of these metrics calculated across a sliding window of the specified size.","failureModes":["Empty or missing pnls array returns a validation error","Array length exceeding 5000 items is rejected","Non-numeric values in the pnls array cause a schema validation failure","Rolling window larger than the number of supplied P&L values may produce empty or undefined rolling statistics","All-zero P&L array may produce undefined profit factor (division by zero)","All-winning trades produce a profit factor of infinity or undefined gross-loss scenario"],"whenToPreferThis":"Choose this endpoint when you have a pre-computed array of realized trade P&L values and need standard performance statistics (win rate, profit factor, max drawdown, rolling metrics) without any market data access or brokerage integration. It is a pure computation service — ideal for backtesting pipelines, trade journal analytics, and strategy comparison workflows where the P&L data is already available locally.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-01T18:13:26.301Z","isFirstParty":false,"canonicalSlug":"p-l-stats-calculator-59cb7efc"}