> For the complete documentation index, see [llms.txt](https://basedapp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://basedapp.gitbook.io/docs/trading/entry-price-pnl.md).

# Entry Price / PnL

<figure><img src="/files/t0E1DJER6Tcq4pT7rJRQ" alt=""><figcaption></figcaption></figure>

## Entry Price and PnL

{% hint style="info" %}
Entry price, unrealized PnL, and closed PnL are client-side calculations meant for user clarity — they are not part of the protocol's on-chain accounting, which is instead based solely on margin (for perps) or balances (for spot) and executed trades.
{% endhint %}

***

## Perpetuals (Perps)

### Opening vs. Closing Trades

* An **opening trade** increases the absolute size of your position — e.g., going longer while already long, or adding to a short.
* A **closing trade** reduces your position size in the opposite direction.

For example, if you are long 1 ETH and buy 0.5 more ETH, this is an opening trade. If you then sell 0.5 ETH, this is a closing trade.

### Entry Price Logic

* For opening trades, the entry price is recalculated using a size-weighted average of the current entry price and the new trade price.
* For closing trades, the entry price remains unchanged.

### Unrealized PnL

```
Unrealized PnL = side * (mark_price - entry_price) * position_size
```

Where `side` = 1 for long, -1 for short.

### Closed PnL

For closing trades:

```
Closed PnL = fee + side * (mark_price - entry_price) * position_size
```

For opening trades, the closed PnL equals only the fee paid — there is no exit price calculation since no position is being reduced.

## Spot

Spot PnL calculations follow similar logic to perps with a few key differences:

* Buys are treated as opening trades, and sells as closing trades.
* Transfers are treated as buys or sells at the current mark price.

{% hint style="info" %}
UBTC on Hyperliquid always matches the BTC held in custody, maintaining a 1:1 peg.
{% endhint %}

***

## Viewing Your PnL

You can view your account balance, unrealized PnL, and trade history directly in the BasedApp terminal.

<figure><img src="/files/CYCf8hLKCSApHFmOXP8A" alt=""><figcaption></figcaption></figure>
