# Entry Price / PnL

**Entry Price and PnL**

Entry price, unrealized PnL, and closed PnL are client-side calculations meant for user clarity — they are not part of the protocol’s onchain accounting, which is instead based solely on margin (for perps) or balances (for spot) and executed trades.

***

**Perpetuals (Perps)**

* A trade is considered opening if it 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.

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 Formula: Unrealized PnL = side × (mark\_price − entry\_price) × position\_size&#x20;

Closed PnL Formula: Closed PnL = side × (exit\_price − entry\_price) × position\_size + fees

**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.


---

# 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://nikafinance.gitbook.io/docs/trade-and-earn/trade-perps/entry-price-pnl.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.
