Skip to content

⚠︎ Risk warning: leveraged derivatives on unregulated platforms — you can lose everything you deposit. Not investment advice.

Guide · By · Updated 2026-09-15

Hyperliquid Entry Price, Unrealised and Closed PnL

Formulas verified against Hyperliquid's official docs on 2026-09-15.

The docs open the topic with a sentence worth keeping: "entry price, unrealized pnl, and closed pnl are purely frontend components provided for user convenience. The fundamental accounting is based on margin (balance for spot) and trades." Your balance is what the chain tracks; the PnL numbers are a readable view on top of it. Here is how that view is built.

Opening versus closing

"Perp trades are considered opening when the absolute value of the position increases. In other words, longing when already long or shorting when already short." Everything else is closing. This distinction drives the entry price: "for opening trades, the entry price is updated to an average of current entry price and trade price weighted by size. For closing trades, the entry price is kept the same." Add to a long at a higher price and your entry rises; trim it and your entry stays where it was.

The two PnL numbers

unrealized_pnl = side * (mark_price - entry_price) * position_size
closed_pnl     = fee + side * (mark_price - entry_price) * position_size   (closing trade)
closed_pnl     = fee                                                        (opening trade)
side = 1 long, -1 short

Two consequences follow. Unrealised PnL moves with the mark price, not with the last trade or your own fills, so it can change while nothing trades. And closed PnL carries the fee: an opening trade shows closed PnL equal to its fee alone, and a closing trade's closed PnL is the price difference net of that trade's fee. Funding payments are not part of either formula on that page; how they settle is on this site's funding guide.

Spot

"Spot trades use the same formulas as perps with the following modifications: Spot trades are considered opening for buys and closing for sells." Three rules cover edge cases: "transfers are treated as buys or sells at mark price", "genesis distributions are treated as having entry price at 10000 USDC market cap" (because "0 is the correct answer" but "leads to undefined return on equity"), and "pre-existing spot balances are assigned an entry price equal to the first trade or send after the feature was enabled around July 3 08:00 UTC" — the docs give no year for that date.

Why "available" and "PnL" can disagree

Closing a position at a profit does not necessarily lift Available Balance by the profit, and closing at a loss does not necessarily lower it by the loss, when other cross positions are underwater: the support FAQ explains that new margin "goes toward these existing positions" that no longer meet their initial margin requirement. Total Balance reflects the trade; Available Balance reflects what is not reserved. The unified-account page walks through the FAQ's example.

FAQ

Why is my closed PnL slightly negative on a flat trade?

Because it includes the fee: a closing trade at exactly the entry price shows closed PnL equal to minus the fee, and the opening trade already showed its own fee.

Does reducing a position change the entry price?

No. "For closing trades, the entry price is kept the same."

Is the PnL on screen what the chain records?

The chain records margin and trades; entry price and PnL "are purely frontend components". They are derived from on-chain data, not stored as such.

Open Hyperliquid (opens in a new tab)

Referral link — 4% fee discount, disclosed on the referral page. See our methodology.