{"uid":"cap_nxZ2zfvJg9KYXkQteOSsp","slug":"leveraged-trade-risk-preflight-query-bd7d6f13","name":"Leveraged Trade Risk Preflight Query","description":"Size a hypothetical long or short from account risk, stop, leverage, fees, and slippage; return a conservative liquidation-distance warning without placing a trade.","url":"https://proofwork-codex-0902.ophl.link/x402/leveraged-trade-risk-query?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD","DELETE"],"type":"string"},"queryParams":{"type":"object","title":"TradeRiskInput","required":["side","account_equity_usd","entry_price","stop_price"],"properties":{"side":{"enum":["long","short"],"type":"string","title":"Side"},"leverage":{"anyOf":[{"type":"number","maximum":200,"minimum":1},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"}],"title":"Leverage","default":"1"},"stop_price":{"anyOf":[{"type":"number","maximum":1000000000000,"exclusiveMinimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"}],"title":"Stop Price"},"entry_price":{"anyOf":[{"type":"number","maximum":1000000000000,"exclusiveMinimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"}],"title":"Entry Price"},"risk_percent":{"anyOf":[{"type":"number","maximum":100,"exclusiveMinimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"}],"title":"Risk Percent","default":"1"},"target_price":{"anyOf":[{"type":"number","maximum":1000000000000,"exclusiveMinimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"},{"type":"null"}],"title":"Target Price","default":null},"fee_bps_per_side":{"anyOf":[{"type":"number","maximum":5000,"minimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"}],"title":"Fee Bps Per Side","default":"5"},"account_equity_usd":{"anyOf":[{"type":"number","maximum":1000000000000,"exclusiveMinimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,13}|(?=[\\d.]{1,22}0*$)\\d{0,13}\\.\\d{0,8}0*$)"}],"title":"Account Equity Usd"},"slippage_bps_per_side":{"anyOf":[{"type":"number","maximum":5000,"minimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"}],"title":"Slippage Bps Per Side","default":"5"},"maintenance_margin_percent":{"anyOf":[{"type":"number","maximum":50,"minimum":0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,4}|(?=[\\d.]{1,9}0*$)\\d{0,4}\\.\\d{0,4}0*$)"}],"title":"Maintenance Margin Percent","default":"0.5"}},"description":"Bounded inputs for one hypothetical long or short trade.","additionalProperties":false}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":null,"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_xBGxjg3tBXD3eBxQl5Wy2","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":"Calculates position sizing, risk metrics, and liquidation-distance warnings for a hypothetical leveraged long or short trade without placing any order.","exampleAgentPrompt":"Before I open a 10x leveraged long on BTC with my $5,000 account, entry at $65,000 and stop at $63,500, risking 1% of equity — can you run a risk preflight to show me my position size, fees at 5 bps per side, and how far my liquidation is from my stop?","exampleUseCases":[{"title":"Crypto leveraged long sizing check","prompt":"I want to go long ETH at $3,200 with a stop at $3,050 on a $10,000 account using 5x leverage and 1% risk — can you calculate my position size and warn me if liquidation is dangerously close to my stop? Assume 5 bps fees per side."},{"title":"Short trade risk before earnings","prompt":"I'm thinking of shorting a stock at $150 with a stop at $155, targeting $138, using 3x leverage on my $25,000 account with 1.5% risk — run a preflight so I know my size and whether my liquidation distance is safe at 10 bps fees per side."},{"title":"High-leverage liquidation distance sanity check","prompt":"I'm considering a 50x leveraged long with entry at $2.50 and stop at $2.40 on a $500 account risking 2% — please check whether my liquidation price would be above my stop loss and give me a conservative warning before I do anything."}],"resultDescription":"Returns computed position size in base units and USD notional, dollar and percentage risk, estimated fee and slippage costs, reward-to-risk ratio if a target is provided, and a conservative liquidation-distance warning indicating how far the liquidation price is from the stop loss level — all without placing any trade.","failureModes":["Missing required fields (side, account_equity_usd, entry_price, stop_price) returns a 400 validation error","Stop price on the wrong side of entry for the given direction triggers an input validation error","Leverage out of range (below 1 or above 200) is rejected","Negative or zero equity or price values are rejected","Extremely tight stop with very high leverage may produce a warning that liquidation is above/below the stop, signaling an unsafe trade setup","Payment failure (402) if USDC micropayment not included or insufficient"],"whenToPreferThis":"Use this endpoint when an AI agent or trading system needs to validate the risk parameters of a hypothetical leveraged trade before execution — especially when the agent must confirm that a stop loss is not inside the liquidation zone. Prefer this over generic position-size calculators because it explicitly incorporates leverage, fees, slippage, and liquidation distance into a single conservative warning output. Ideal for pre-trade compliance checks, agent-driven risk guardrails, or when a user wants to sanity-check leverage settings without touching a live order.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-19T00:30:42.726Z","isFirstParty":false,"canonicalSlug":"leveraged-trade-risk-preflight-query-bd7d6f13"}