PnL calculations
To calculate the current PnL of a deal you may use the following example for ETH/DAI position:
Assume, we open an ETH/DAI in long using $1000 of DAI as collatral, with x5 leverage and slippage tolerance set to 0.5%, when DAI market price was at $0.99 and ETH market price at $2000 and ETH price rose to $2100
The amount of fees paid for opening a position on the market would be:
The amount of margin reserved for the loan would be:
Using the set order parameters we can calculate the Position Size in USD and ETH excluding the fees incurred, and the minimum size filled considering the current slippage tolerance applied:
Now, we can calculate the amount of fees incurred to our position upon opening:
Next, we would have to calculate the funding rate and funding amounts. General formula to calculate the funding amount is the following:
Where,
For the simplicity of calculations, however, let's assume that the position hasn't been open for an hour yet, thus the funding fee has not yet been charged.
In order to find the PnL value, we would first need to calculate the current market prices for the position in DAI and ETH.
Now, in order to calculate the PnL of our position we have to find the difference between the current collateral market price and the open collateral market price:
Last updated