Realized PnL

Realized profit and loss is the result a closing trade turns into cash, with the fee of that trade counted in it.

Definition

Hyperliquid calls it closed pnl, and gives it as the fee plus the price difference times the size, signed by the side, for a closing trade, and as the fee alone for an opening one. Opening a position therefore shows a small negative figure at once, which is simply its fee. Like the entry price and unrealized pnl, closed pnl is a frontend component provided for convenience: the accounting underneath is margin and trades.

What belongs to it and what does not is worth separating. The fees of both legs do, at 0.045% of the notional for a taker and 0.015% for a maker at the base perps tier. Funding does not: it is added to or subtracted from the balance every hour while the position is held, so it is cash of its own, independent of how the trade ends. A liquidation realizes the loss like any close, and in a backstop liquidation the maintenance margin is not returned on top.

The gap between a large unrealized profit and a smaller realized one is ordinary, and it has three parts: the exit pays the spread, it pays whatever slippage its size costs, and it pays a second fee. That is why our simulation account keeps the totals apart rather than netting them: the cash, the venue's fees, the service fee, the funding and the realized result each have their own line, kept on a grid of millionths of a dollar so a running total never drifts from the sum of what was paid.

Formula

closed_pnl = fee + side * (mark_price - entry_price) * position_size for a closing trade, and the fee alone for an opening trade, with side = 1 for a long and side = -1 for a short.

Example

An example, in round figures. A long of 1 BTC entered at $100,000 and closed at $105,000 realizes $5,000 on the price. Two taker legs at the base rate of 0.045% cost $45 at the entry and $47.25 at the exit, so $92.25, which leaves $4,907.75 before funding. Every hour the position was held also paid or received funding, separately, and that figure is not in the trade's own result.