To calculate the Realised Profit and Loss (Realised PNL) you see on the Balances page, you will need to account for all of the trades that you’ve made within that 24 hour period, between 12:00 PM UTC and 12:00 PM UTC the next day.
For example, to calculate the Jan 18th Realised PNL (-0.00007324 XBT) shown below:
We’ll have to account for the trades that were made between January 17th 12:00 PM UTC and January 18th 12:00 PM UTC as shown on the Trade History page:
Order e78e4a1 from the screenshot above was partly closed with orders 5403897 so that’s the first pair of trades we’ll need to calculate the Unrealised PNL for using the following formula:
Unrealised PNL = Number of lots * Multiplier * (100/Average Entry Price - 100/Exit Price)
* The (100/Price) values will need to be rounded to 8 decimal places for accuracy
UnrealisedPNL = 5 * 1 * (100/42292.5 - 100/42303)
= 5 * 1 * (0.00236449 - 0.0023639)
= 0.00000295 XBT
You can double-check that you’ve calculated the UnrealisedPNL correctly by using the BitMEX calculator.
Now that we got the Unrealised PNL, we can use the formula below to calculate Realised PNL for those trades:
Realised PNL = Unrealised PNL - taker fee + maker rebate -/+ funding payment
Realised PNL = 0.00000295 - 0.00002954
= -0.00002659 XBT
The remainder of e78e4a1 was fully closed with afe5cda within that 24 hour period, so we will have to calculate the PNL for this pair as well:
Unrealised PNL = 15 * 1 * (100/42292.5 - 100/42107.5)
= 15 * 1 * (0.00236449 - 0.00237487)
= -0.0001557 XBT
Realised PNL = -0.0001557 - 0.0000178
= -0.0001735 XBT
To put it all together and get the total RealisedPNL for Jan 18th, we will have to add the Realised PNL for the two pairs of trades and the funding payment that was paid during this time:
Jan 18th Realised PNL = Realised PNL for trade e78e4a1 & 5403897 + Realised PNL for e78e4a1 & afe5cda + funding payment received
= -0.00002659 -0.0001735 + 0.00012685
= -0.00007324 XBT