"Profit and Loss" (P&L) represents the gains or losses you have accrued between opening and closing a position.
How Profit and Loss is calculated
Your unrealized Profit and Loss for an existing position is calculated as follows:
LONGS: P&L = position_size * (mid_market_price - average_open_price)
SHORTS: P&L = position_size * (average_open_price - mid_market_price)
Here's a quick example. Assume that the current price of ETH is $200. If you opened a 10 ETH Long position when ETH was worth $100, your PNL would be as follows:
10 * ($200 - $100) = $1,000
We also list your P&L as a percentage of your collateral. So if the above example was a 2x long, the initial collateral would be 5ETH, initially worth $500. So the P&L percentage would be:
$1,000/$500 = +200%
At any time you can always calculate the P&L value we display on the screen by using your position size, average open price, and mid market price.
Why is my P&L immediately negative after opening a new position?
When you open a position, your average_open_price is going to be slightly different than the mid_market_price. This is because the orderbook will always have a small spread to it (the difference between the best ask and best bid prices).
P&L is calculated using the difference between mid_market_price and the average_open_price, so freshly opened positions will be very slightly negative in value.
Understanding Profit and Loss in the Pro Mode
While the P&L in the basic mode is fairly straightforward, there are some interesting cases in the Pro Mode that could make the P&L value a little more complex. The above formulas remain the same, but there are a few events that can modify the key variables we use to calculate P&L. These are:
- Depositing additional collateral into an existing position
- Withdrawing collateral from an existing position
- Making additional trades with an existing position
When you deposit or withdraw additional collateral into your margin account, your average_open_price will change. It assumes mid_market_price for the deposit or withdraw action. Adjusting the average open price keeps the logic of the P&L sound: depositing or withdrawing additional collateral will not artificially inflate/deflate your displayed P&L.
If you make additional trades with your existing position, you can change your position size, position type (long/short), and your average open price. Again, we do this to maintain consistency in your P&L value. The goal here is to have the P&L be as accurate as possible, regardless of what actions you take with your position, so you can accurately understand how well your position is doing!