{"uid":"cap_ZMRQXj0uNrlpyE7rgYFSf","slug":"finmath-position-size-calculator-4f8e13be","name":"finmath Position Size Calculator","description":"Deterministic finance and crypto math for AI agents: TradFi (NPV, IRR, XIRR, Black-Scholes + Greeks, bonds, VaR, Sharpe) and DeFi (impermanent loss, perp liquidation, funding, Uniswap v3, health factor, cost basis). Exact, model-free arithmetic that LLMs get wrong — priced per call in USDC.","url":"https://finmath.qzqh5rrbkz.workers.dev/v1/position_size","method":"POST","headers":{},"bodySchema":{"type":"object","required":["stop_price","entry_price","risk_fraction","account_equity"],"properties":{"stop_price":{"type":"number","description":"stop_price"},"entry_price":{"type":"number","description":"entry_price"},"risk_fraction":{"type":"number","description":"risk_fraction"},"account_equity":{"type":"number","description":"account_equity"}}},"responseSchema":{"type":"object","required":["result","meta"],"properties":{"meta":{"type":"object"},"result":{}}},"example":{"request":{"stop_price":95,"entry_price":100,"risk_fraction":0.02,"account_equity":10000},"response":{"meta":{"tool":"position_size","model":true,"disclaimer":"Deterministic calculation utility. Not financial, investment, or trading advice.","assumptions":["loss-at-stop sizing; ignores fees, slippage, and gaps through the stop"],"deterministic":true},"result":{"units":40,"notional":4000,"risk_amount":200,"implied_leverage":0.4}}},"exampleRequest":{"stop_price":95,"entry_price":100,"risk_fraction":0.02,"account_equity":10000},"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm__XOLxP-Y2Ca4wtXBddocj","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calculates optimal position size for a trade given account equity, entry price, stop price, and risk fraction using exact arithmetic","exampleAgentPrompt":"I have a $50,000 account and I want to buy ETH at $3,200 with a stop loss at $3,000 — I'm willing to risk 1% of my equity on this trade. How many units should I buy?","exampleUseCases":null,"resultDescription":"Returns the mathematically exact position size (number of units to trade) so that the total loss if the stop price is hit equals exactly the specified risk fraction of the account equity, along with metadata about the calculation.","failureModes":["Missing required fields (stop_price, entry_price, risk_fraction, account_equity) returns validation error","risk_fraction outside 0-1 range may produce nonsensical results","entry_price equal to stop_price causes division by zero","Negative equity or price values may return error or undefined behavior","Payment failure (402) if USDC balance insufficient"],"whenToPreferThis":"Use this endpoint when you need deterministic, exact position sizing arithmetic — especially when LLM-native math might be unreliable. Ideal for trading agents that need to size positions precisely based on account equity, a defined entry, and a hard stop loss level, without relying on probabilistic model outputs.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T18:51:47.789Z","isFirstParty":false}