# Entry price and P\&L (Profit and Loss)

Profit and Loss (P\&L) is a crucial metric determining the financial outcome of trading positions. It is calculated based on the entry price and the current market price. There are three primary types of P\&L: Unrealized P\&L, Realized P\&L and Closed P\&L. Understanding these concepts is essential for managing risks and maximizing profitability.

## Calculating the Average Price

At this stage, EVEDEX supports only a single position per contract, which can be either long or short. When traders adjust their position by buying or selling additional contracts, the average price is recalculated within that same contract. Consequently, all P\&L calculations are based on this new average price.

The average price of an asset is calculated using the following formula:

*Average Price = Total Coin Value / Total Coins*

Where Total Coin Value is determined as:

*(Quantity1 × Price1) + (Quantity2 × Price2) + ...*

**Example:**

* First trade: 0.5 BTC purchased at $15,000
* Second trade: 0.2 BTC purchased at $14,000

Total Coin Value: (0.5 × 15,000) + (0.2 × 14,000) = 10,300

Total Coins: 0.5 + 0.2 = 0.7

Average Price: $14,714

## Types of P\&L

### Unrealized P\&L

Unrealized P\&L represents the potential profit or loss of an open position. It fluctuates in real-time based on market price movements and is not finalized until the position is closed.

#### Unrealized P\&L Calculation

For long positions:

*Unrealized P\&L = Quantity × (Last Price - Entry Price)*

For short positions:

*Unrealized P\&L = Quantity × (Entry Price - Last Price)*

**Example**:

A trader buys 0.5 BTC at $15,000. If the last market price is $15,500, then:

Unrealized P\&L = 0.5 × (15,500 - 15,000) = 250 USDT

For a short position, if the trader enters at $15,000 and the market price increases to $15,500, then:

Unrealized P\&L = 0.5 × (15,000 - 15,500) = -250 USDT (a loss of 250 USDT)

### Realized P\&L

Realized P\&L indicates actual profits or losses from closed or partially closed trades, including fees and funding.

**Example:**

A trader initially holds 0.5 BTC at $15,000. They decide to sell 0.25 BTC at $14,000.

Position's P\&L = 0.25 × (15,000 - 14,000) = 250 USDT

* **Opening fee:** 0.25 × 15,000 × 0.02% = 0.75 USDT
* **Closing fee:** 0.25 × 14,000 × 0.02% = 0.7 USDT
* **Funding fee:** 2 USDT

Final Realized P\&L = 250 - (0.75 + 0.7 + 2) = 246.55 USDT

The trader now holds 0.25 BTC. They decide to buy an additional 0.2 BTC at $13,500.

Opening Fee: 0.2 × 13,500 × 0.02% = 0.54 USDT

Updated Realized P\&L = 246.55 - 0.54 = 246.01 USDT

The trader’s current position is 0.45 BTC, which is short. If the trader chooses to open long on 1 BTC, the existing short position on 0.45 BTC will be closed, and the Realized P\&L will be calculated for the remaining 0.55 BTC in the long position.

### Closed P\&L

Closed P\&L represents the final profit or loss once all positions are closed. It factors in all trading fees, funding fees, and executed orders.

### Key Considerations in P\&L Calculations

* Leverage does not directly affect P\&L amounts but changes the margin requirements.
* Higher leverage decreases margin but increases risk.
* P\&L scales with position size and price movement.
* Fee structures impact realized and closed P\&L.

### Leverage Impact on ROI

* 10x leverage: 250 USDT profit → 33.27% ROI
* 5x leverage: 250 USDT profit → 16.63% ROI
* 20x leverage: 250 USDT profit → 66.54% ROI


---

# 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.evedex.com/key-features-and-components/trading-platform-and-matching-engine/entry-price-and-pnl-profit-and-loss.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.
