# Profit, Loss, and ROI

## Realized Profit and Losses&#x20;

Realized Profit and Loss (rPnL) are used to convey a position's total profit/ loss that has been resolved (paid or received). This includes all accumulated paid fees, such as the Open Position Fee, and is calculated as follows for each $$i$$ of all $$N$$partial closes.

$$
rPnL = paidFees + \sum\_{i=1}^N \begin{cases} (closePrice\_i - avgEntryPrice\_i)\times posQty\_i &\text{if } LONG \ (avgEntryPrice\_i - closePrice\_i)\times posQty\_i &\text{if } SHORT\end{cases}
$$

## Unrealized Profit and Losses

Unrealized Profit and Loss (uPnL) track the profit or loss of an open position, taking into account all unpaid accrued fees.

$$
uPnL = accruedFees +  \begin{cases} (markPrice - avgEntryPrice)\times posQty &\text{if } LONG \ (avgEntryPrice - markPrice)\times posQty &\text{if } SHORT\end{cases}
$$

Note: Paid fees and/or accrued fees can be either negative (losses to trader) or positive (profits to trader) which occurs in cases where the funding rate is negative (ie: Short position when LongOI > ShortOI).

## Return on Investment (ROI)

Return on Investment is used to establish how profitable a given trade is, and is a key metric in showcasing a trader's ability during competitions. We use the following calculation to determine position ROI for rPnL where max collateral is determined by the greatest number the collateral has reached for the position up until the time of each partial $$i$$ rPnL.

$$
ROI (rPnL) = \sum\_{i=1}^N rPnl\_i/maxCollateral\_i
$$

The ROI for uPnL is simply calculated as follows:

$$
ROI (uPnL) =  uPnl/positionCollateral
$$


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.navigator.exchange/trade/isolated-margin/stable-pool/profit-loss-and-roi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
