# PnL Calculation

What's PnL?

PnL is the profit or loss a trader makes on their trades. It can be realized or unrealized, and it takes into account factors such as trading fees, funding fees, and position size.&#x20;

The unrealized PnL is the profit or loss that a trader has on their open positions, and it changes in response to market movements. Realized PnL is the profit or loss a trader realizes when they close their position, taking into account the executed price of the position, trading fees, and funding fees.

The calculation of profit and loss (PnL) is based on the collateral, taking into account both trading direction and position size. At NFEX, the perpetual contracts are linear contracts, meaning that they are quoted, denominated, and settled in ETH.

The unrealized profits and losses are calculated based on the`Mark Price`, whereas the realized profits and losses are calculated based on the executed price of the position.

## Calculation

### 1. Unrealized PnL

The unrealized PnL of open positions is the profit or loss that a trader would make if they were to close their position at the current market price. It is calculated based on the difference between the trader's average open price and the current mark price of the contract and is denominated in ETH, since all perpetual contracts on NFEX are settled in ETH. This value changes in real-time as the market price of the underlying asset fluctuates, and can be positive or negative depending on the direction of the trade and the current market conditions.

The calculation is as below:

&#x20;**Long position：**

$$Unrealized PnL=Number of Contract\times Contract Size \times(Mark Price - Open Price)$$

**Short Position:**

$$Unrealized PnL=Number of Contract\times Contract Size \times(Open Price-Mark Price)$$

### 2. Realized PnL

Realized PnL is the difference between the open price and close price when the position of the contract is closed out. The value is calculated in ETH and has no direct relation to Mark Price but to the last traded price of the closed position. The funding payments and trading fees will be added to the realized PnL. The calculation is as below:

$$Realized PnL=Closing PnL- OpenOrderFee- CloseOrderFee\pm Funding$$

Where:

* *for long positions,* $$Closing PnL =Number of Contract \times  Contract Size \times  (Executed Price - Open Price )$$
* *for short positions,* $$Closing PnL =Number of Contract \times  Contract Size \times  (Open Price - Executed Price)$$

{% hint style="info" %}
**Please Note:**

The constantly-changing unrealized PnL will increase or decrease the available collateral for maintenance margin and thus become a primary driver for liquidations.&#x20;
{% endhint %}

{% hint style="success" %}

## **Join Our Community**

* **Twitter**: <https://twitter.com/nfex_official>
* **Discord**: <https://discord.gg/nfex>
* **Medium**: [https://medium.com/@nfex.official](https://medium.com/@nfex.official/)
  {% endhint %}


---

# 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://nfex.gitbook.io/docs/nfex-perpetual-guide/pnl-calculation.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.
