Skip to content

Docs / Product

Planner math

The position-sizing formulas, the rounding rule, cost assumptions and the liquidation estimate.

The basic calculation

stopDistance           = |entryPrice − stopPrice|
quantity               = riskBudget ÷ stopDistance
notional               = quantity × entryPrice
estimatedInitialMargin = notional ÷ leverage

This is for a linear, USDC-margined perpetual: profit and loss equal price change times quantity. It excludes fees, funding and slippage. All arithmetic is decimal, never floating point.

Rounding

With a market selected, the quantity is rounded down to that market's size step, never up, and the risk is recalculated from the rounded quantity. The loss shown is therefore the loss of the size you could actually send, and it is at or under your budget.

Cost-adjusted size

If you enter a fee per side and a slippage assumption, a second size is shown that fits those costs inside the budget:

perUnitRisk = stopDistance
            + (entry + stop) × feeRate        (a fee on each fill)
            + (entry + stop) × slippageRate   (adverse slippage on each fill)
quantity    = riskBudget ÷ perUnitRisk

The fee defaults to the venue's base taker rate; your own tier may differ. Slippage is your assumption, not a measurement. Funding is not part of either size.

What leverage changes

Leverage changes the margin a position needs and how close its liquidation price sits. It does not change profit or loss for the same quantity. The planner therefore shows the same quantity and the same loss at 2x and at 20x; only the margin and the liquidation estimate move.

Liquidation estimate

Liquidation is never derived from a generic formula. For a new isolated position the planner uses Hyperliquid's documented rule (maintenance margin rate = 1 ÷ (2 × the tier's maximum leverage), with the venue's margin tiers):

long : liq = (entry × size − margin − deduction) ÷ (size × (1 − rate))
short: liq = (entry × size + margin + deduction) ÷ (size × (1 + rate))
margin = entry × size ÷ leverage

It ignores fees and funding. Under cross margin the liquidation price depends on the whole account, so the planner shows Unavailable and the venue's own figure appears once the position is open. If your stop sits beyond the estimate, the planner warns that the position would be liquidated before the stop is reached.

Validation

  • Entry, stop and risk budget must be positive; the stop distance cannot be zero.
  • A long's stop is below its entry and its target above; a short's the reverse.
  • Leverage is at least 1x, a whole number on a selected market, and within the market's limit and margin tier.
  • The order must be worth at least the venue minimum ($10) and at least one size step.

Saved plans

Plans can be saved, edited, duplicated, exported as a file and sent into the order preview, where they arrive as a limit order with the stop and target attached. They are stored in this browser only.