All articles
Risk·April 1, 2026·6 min read

Position Sizing for Hyperliquid Bots: Kelly, Vol-Targeting, ADL Risk

Position sizing for a Hyperliquid trading bot means more than Kelly. Size perps against ADL queues, OI caps, and leverage tiers with vol-targeting that survives squeezes.

Naive Kelly will get you liquidated on Hyperliquid faster than almost anywhere else, and not because the math is wrong. Kelly assumes your fill size doesn't move the market, that your position can always be closed at mid, and that nobody can force you out at a price you didn't choose. On a perp DEX with an auto-deleveraging (ADL) queue and per-asset open-interest caps, all three assumptions break. Position sizing here is a systems problem, not a formula you copy from a Thorp paper.

Here's how we size perp positions in production, and the specific Hyperliquid mechanics that override the textbook answer.

Start with fractional Kelly, then throw most of it away

The full-Kelly fraction for an edge with win probability p and payoff ratio b is f = p - (1-p)/b. If your backtested strategy wins 55% of the time at 1:1, full Kelly says risk 10% of equity per bet. Do not do that. Full Kelly is the point of maximum long-run growth and maximum drawdown; a 50% drawdown is routine at full Kelly and your parameter estimates are noisy anyway.

We run quarter-Kelly as a ceiling, never a target:

def kelly_fraction(p, b, cap=0.25):
    f = p - (1 - p) / b
    return max(0.0, min(f * 0.25, cap))  # quarter-Kelly, hard-capped

The max(0.0, ...) matters more than it looks. When your live edge decays and p slips under the breakeven, raw Kelly goes negative — which naively means "flip the position." That's a footgun. You want zero size and an alert, not an auto-reversal on a stale estimate. The same discipline that catches a decayed edge is the one that catches bad oracle data; if you haven't already, the reasoning in our writeup on circuit breakers for stale oracles and depeg halts applies directly to sizing gates.

Vol-targeting is what actually sets the number

Kelly tells you the fraction of edge. Vol-targeting tells you the fraction of capital so that your dollar risk stays constant as market volatility swings. This is the piece most bots skip, and it's why their equity curve looks fine in calm regimes and detonates in a squeeze.

Target an annualized portfolio vol — say 20% — and size each position inversely to its realized vol:

def vol_target_notional(equity, target_vol, asset_vol, price):
    # target_vol and asset_vol are annualized (e.g. 0.20, 0.90)
    dollar_risk = equity * (target_vol / asset_vol)
    return dollar_risk / price  # position size in coin units

Estimate asset_vol from an EWMA of returns with a lambda around 0.94 on hourly bars, not a fixed 30-day window. HYPE and the memecoin perps can triple their realized vol in an afternoon; a slow window keeps you oversized right into the move. The final coin quantity is the minimum of the Kelly-scaled size and the vol-targeted size. Kelly is your edge ceiling, vol-targeting is your risk ceiling, and you take whichever is smaller.

The Hyperliquid-specific constraints that override both

Now the part the textbooks don't cover.

Per-asset OI caps and the max-leverage tiers

Every Hyperliquid asset has a maximum leverage tier and an open-interest cap enforced at the protocol level. BTC and ETH sit at 40x–50x; smaller listings drop to 20x, 10x, or 3x, and the OI cap on a thin market can be a few million dollars total. Two consequences for sizing:

  • Your maintenance margin is a function of your chosen leverage tier, and it's tiered by position size. A position that's comfortable at 5x can be one adverse candle from liquidation at 20x. Size against maintenance margin, not initial.
  • If a market is near its OI cap, your order can be rejected or you become a large fraction of total OI — which puts you at the front of the ADL queue (more below). Pull the OI and cap from the metaAndAssetCtxs info endpoint before every sizing decision and treat "we'd be >X% of OI" as a hard block.

Auto-deleveraging is a sizing input, not an afterthought

When the insurance fund can't absorb a liquidation, Hyperliquid closes the bankrupt account against profitable traders on the other side, ranked by profit and leverage. High unrealized PnL and high leverage puts you at the top of that queue. You can be right, in profit, and still get force-closed at the mark price during a violent move — no slippage control, no say in the timing.

So ADL risk is inversely correlated with how conservatively you size. The mitigation is boring and effective: cap per-asset leverage well below the tier maximum (we rarely exceed 5x on majors, 2x on thin names), and treat large unrealized profit as a reason to trim, not to press. If getting ADL'd out of a winner would break your strategy's accounting, that's a sizing bug, and it's the kind of thing a second pair of eyes catches — we flag it constantly in a trading-bot code review and audit.

Fills move the mark, and the mark moves your margin

Hyperliquid's mark price blends the oracle with the order book. A size big enough to walk the book on entry can shift the mark against your own margin the instant you're filled. The same slippage-and-impact discipline we use for Jupiter swap guardrails applies here: model expected price impact at your intended size, and if the impact plus fees eats more than a fraction of your per-trade edge, the position is too big regardless of what Kelly said.

A worked example

Account equity: $50k. Signal on ETH-PERP, backtested p=0.56, b=1.1. ETH realized vol (EWMA, annualized): 60%. Target portfolio vol: 20%. ETH at $3,000.

  • Quarter-Kelly fraction: (0.56 - 0.44/1.1) * 0.25 = 0.04 → edge ceiling ~$2,000 of risk.
  • Vol-target notional: 50000 * (0.20/0.60) = $16,667 notional → ~5.5 ETH.
  • Check OI cap: fine, we're a rounding error of ETH OI.
  • Check ADL/leverage: at $16.7k notional on $50k equity that's ~0.33x account leverage — comfortably clear of the ADL queue.

Take the smaller effective constraint, set a stop that keeps maintenance margin healthy, and you've got a size that survives a squeeze instead of feeding one.

Wire it as a pipeline, not a formula

The mistake is treating sizing as one function returning one number. In production it's a pipeline where each stage can only shrink the size: Kelly ceiling → vol target → OI/leverage check → ADL-queue check → impact check. The final size is the min across all of them, recomputed on live state every cycle. When your funding history or margin fractions drift, the pipeline should degrade gracefully rather than silently oversize — the same defensive posture we apply to pre-settlement resolution risk on Polymarket.

None of this is static. Vol regimes shift, Hyperliquid adjusts OI caps and leverage tiers, and a sizing model that was calibrated in March is stale by summer — which is exactly why we keep sizing logic under an ongoing support and maintenance contract rather than shipping it once and walking away. Seeing the whole constraint stack on one screen also helps; a live trading dashboard that surfaces margin fraction, ADL rank, and OI utilization per position turns "why did we get force-closed" from a post-mortem into a glance.

If you're building or hardening a Hyperliquid bot and want the sizing pipeline stress-tested before it's live, a focused code review and audit is the cheapest insurance you'll buy this quarter.

Need a bot like this built?

We design, build and run trading bots on Solana, Hyperliquid and Polymarket.

Start a project
#hyperliquid#position-sizing#risk-management#perpetuals#kelly-criterion