PnL And Total Account Value

PnL (Profit and Loss)

Unrealized PnL represents the potential gain or loss an account would incur by closing all its open positions. It is calculated based on the difference between the average entry price of the positions and the current mark price.

Let posipos_i be the current position size of an account. posipos_i is positive if the account position is long and negative if it is short. The unrealized PnL of the account can be calculated as:

Unrealized PnL:=(markPriceiavgEntryPricei)×positioni \text{Unrealized PnL} := \sum(\text{markPrice}_i - \text{avgEntryPrice}_i) \times position_i

Realized PnL is the gain / loss that has already been captured from the position after closing or due to funding payments. It is calculated based on the difference in USDC value between your average entry price and exit price. Additionally, all funding payments for the position are immediately applied to its realized PNL.

  • When the user is closing a portion of an existing long or short position, average entry price stays the same and exchange realizes the difference in average exit and entry prices.

ΔCollateral:=(exitPriceiavgEntryPricei)×Δpositioni\Delta Collateral := (\text{exitPrice}_i - \text{avgEntryPrice}_i) \times \Delta position_i
  • When the user is increasing the size of their open position, no PnL is realized. Exchange updates the average entry price according to the following formula

avgEntryPricei,new:=avgEntryPricei,old×positioni,old+tradePrice×tradeSizepositioni,new \text{avgEntryPrice}_{i, new} := \frac{{avgEntryPrice}_{i, old }\times {position_{i, old}} + {tradePrice\times tradeSize}}{position_{i, new}}

Total Account Value

Total Account Value represents the total USDC value of an account in Lighter, including all open positions and collateral. It is calculated as follows:

Total Account Value=Collateral+Unrealized PnL\text{Total Account Value} = \text{Collateral} + \text{Unrealized PnL}

Last updated