{"uid":"cap_2jNVdIYLzBpzvCDlMxBDK","slug":"quantoracle-crypto-leverage-check-596b6479","name":"QuantOracle Crypto Leverage Check","description":"QuantOracle: /v1/crypto/leverage-check","url":"https://api.quantoracle.dev/v1/crypto/leverage-check","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"type":"object","title":"CryptoLeverageCheckIn","required":["asset","direction","entry_price","position_size","collateral","returns"],"properties":{"asset":{"type":"string","title":"Asset","description":"Crypto asset symbol (BTC, ETH, SOL...) — drives the live funding rate + carry"},"returns":{"type":"array","items":{"type":"number"},"title":"Returns","minItems":10,"description":"Daily return series for the asset (>=10) — drives VaR/CVaR + Kelly"},"direction":{"enum":["long","short"],"type":"string","title":"Direction","description":"Position direction"},"collateral":{"type":"number","title":"Collateral","description":"Collateral backing the position (USD)","exclusiveMinimum":0},"mark_price":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}],"title":"Mark Price","description":"Current mark price (defaults to entry_price)"},"entry_price":{"type":"number","title":"Entry Price","description":"Entry price (USD)","exclusiveMinimum":0},"position_size":{"type":"number","title":"Position Size","description":"Notional position size (USD)","exclusiveMinimum":0},"confidence_levels":{"type":"array","items":{"type":"number"},"title":"Confidence Levels","default":[0.95,0.99],"description":"VaR/CVaR confidence levels"},"holding_period_days":{"type":"integer","title":"Holding Period Days","default":1,"minimum":1,"description":"VaR holding period in days"},"maintenance_margin_rate":{"type":"number","title":"Maintenance Margin Rate","default":0.005,"minimum":0,"description":"Maintenance margin rate (0.005 = 0.5%)","exclusiveMaximum":0.5}}},"type":{"type":"string","const":"http"},"method":{"enum":["POST","PUT","PATCH"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false}}},"responseSchema":null,"example":{"request":{"input":{"body":{"asset":"BTC","returns":[0.02,-0.01,0.015,-0.005,0.03,0.01,-0.02,0.025,0.005,-0.015,0.012],"direction":"long","collateral":2000,"entry_price":45000,"position_size":10000,"confidence_levels":[0.95,0.99],"holding_period_days":1,"maintenance_margin_rate":0.005},"type":"http","method":"POST","bodyType":"json"}},"response":{"ms":306.84,"var":{"levels":{"95":{"var_pct":2.1246,"var_usd":212.46,"cvar_pct":2.8163,"cvar_usd":281.63},"99":{"var_pct":3.2571,"var_usd":325.71,"cvar_pct":3.8149,"cvar_usd":381.49}},"volatility_annual":0.2638,"holding_period_days":1},"_meta":{"url":"https://quantoracle.dev","docs":"https://api.quantoracle.dev/docs","powered_by":"QuantOracle"},"asset":"BTC","flags":["liquidation_distance_elevated","paying_funding"],"kelly":{"current_leverage":5,"full_kelly_leverage":22.0612,"half_kelly_leverage":11.0306},"direction":"long","mark_price":45000,"liquidation":{"distance_pct":19.5,"liquidation_price":36225,"max_loss_before_liq_usd":1950},"live_funding":{"stale":false,"regime":"NEUTRAL","source":"okx","funding_rate":0.000029,"annualized_rate":0.0318,"as_of_age_seconds":0,"carry_cost_annual_usd":318}}},"exampleRequest":{"asset":"BTC","returns":[0.02,-0.01,0.015,-0.005,0.03,0.01,-0.02,0.025,0.005,-0.015,0.012],"direction":"long","collateral":2000,"entry_price":45000,"position_size":10000,"confidence_levels":[0.95,0.99],"holding_period_days":1,"maintenance_margin_rate":0.005},"tags":["x402"],"displayCostAmount":"0.015","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.015/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.015","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.015","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_CRjyZRMNWFXOnk_SiHOCe","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.015","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Analyzes a leveraged crypto position to compute VaR, CVaR, Kelly criterion leverage, liquidation price, and risk flags given returns history and position parameters","exampleAgentPrompt":"Check my leveraged BTC long position for liquidation risk and Kelly optimal leverage — I entered at $45,000 with $2,000 collateral on a $10,000 position size and a maintenance margin of 0.5%, using these recent daily returns: [0.02, -0.01, 0.015, -0.005, 0.03, 0.01, -0.02, 0.025, 0.005, -0.015, 0.012], and give me VaR at 95% and 99% confidence over a 1-day holding period.","exampleUseCases":[{"title":"Pre-trade leverage safety check","prompt":"Before I open a 5x long on ETH at $2,800 entry with $1,000 collateral and $5,000 position size, can you check my liquidation distance and whether the Kelly criterion supports this leverage? Use these recent daily returns: [0.018, -0.012, 0.022, -0.008, 0.015, 0.009, -0.017, 0.021] and a 0.5% maintenance margin at 95% and 99% confidence over 1 day."},{"title":"Portfolio risk report for active trade","prompt":"I have an open short on BTC at $44,000 entry with $3,000 collateral and an $18,000 position size. What is my VaR and CVaR at 99% confidence over 1 day, and am I close to liquidation? Maintenance margin is 0.5% and here are my recent returns: [-0.02, 0.01, -0.015, 0.005, -0.03, -0.01, 0.02, -0.025, -0.005, 0.015]."},{"title":"Optimal leverage sizing for new strategy","prompt":"I'm sizing a new long BTC strategy and want to know the full Kelly and half Kelly optimal leverage given these 11 daily returns: [0.025, -0.008, 0.013, -0.006, 0.031, 0.011, -0.019, 0.027, 0.006, -0.014, 0.011], with an entry price of $50,000, $5,000 collateral, $25,000 position size, 0.5% maintenance margin, and 1-day holding period at 95% and 99% confidence."}],"resultDescription":"Returns a structured object with: per-confidence-level VaR and CVaR in both percentage and USD; annualized volatility; liquidation price and distance percentage; max loss before liquidation in USD; current leverage ratio; full and half Kelly optimal leverage values; and a list of risk flags (e.g. 'liquidation_distance_elevated', 'paying_funding') indicating actionable warnings about the position.","failureModes":["Insufficient returns array length may produce unreliable VaR estimates","Position size smaller than collateral may return invalid leverage values","Unsupported asset symbol returns a 400 or empty asset field","Confidence levels outside [0,1) may cause computation errors","Zero or negative entry_price or collateral triggers validation failure","Truncated or malformed JSON body returns 422 unprocessable entity"],"whenToPreferThis":"Choose this endpoint when you need a comprehensive, single-call risk assessment of a leveraged crypto position covering VaR, CVaR, liquidation proximity, and Kelly sizing simultaneously. It is ideal for pre-trade checks, portfolio monitoring, and risk reporting workflows where both statistical risk metrics and practical liquidation thresholds are required. Prefer this over a generic VaR calculator when you also need Kelly criterion leverage guidance and liquidation price specific to crypto perpetual or margin positions.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T06:41:16.943Z","isFirstParty":false}