> For the complete documentation index, see [llms.txt](https://hyperpnl.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://hyperpnl.gitbook.io/docs/trading/entry-price-and-pnl.md).

# Entry Price and PNL

On HYPERPNL, entry price and PnL are shown to help you track your position. The underlying system is based on executed trades, balance, and equity.

When you add to an existing position, the entry price is recalculated as a size-weighted average of your previous entry price and the new trade price. When you reduce or close a position, the entry price remains unchanged.

#### <mark style="color:$warning;">**Unrealized PnL**</mark>

Unrealized PnL represents the profit or loss of an open position and is calculated using the mark price.

Position side definition:

$$
\text{side} =
\begin{cases}
1, & \text{for long positions} \\
-1, & \text{for short positions}
\end{cases}
$$

Unrealized PnL formula:

$$
\text{Unrealized PNL}
\= \text{side} \times (\text{mark\_price} - \text{entry\_price}) \times \text{position\_size}
$$

Unrealized PnL updates in real time and does not affect your balance until the position is closed.

#### <mark style="color:$warning;">**Closed (Realized) PnL**</mark>

Closed PnL is generated only when a position is reduced or closed.

For opening trades, only trading fees apply.\
For closing trades, closed PnL is calculated as:

$$
\text{Closed PnL}
\= \text{side} \times (\text{mark\_price} - \text{entry\_price}) \times \text{position\_size}
$$

Closed PnL directly updates your account balance. Fees are deducted directly from your account balance and do not affect the PnL of an individual position.
