Calculations

  1. Average entry price calculation for positions

Scenario
Sub-scenario
Average Entry Price

New position opened

AvgEntryPrice = TradePrice

New trade for an existing position

Side changed, i.e. long became short or short became long

AvgEntryPrice = TradePrice

Size reduced, i.e. long reduces in size but remains long, or, short reduces in size but remains short

AvgEntryPrice = LastAvgEntryPrice

Size increased, i.e. long increase in size but remains long, or, short increases in size but remains short

AvgEntryPrice = (PreviousSize * LastAvgEntryPrice + TradedSize * TradePrice) / NewSize

P.S.: Fees is not considered while calculating average entry price of positions, total fees for a position is shown separately

  1. Realized Profit and Loss calculation for trades

Scenario
Sub-scenario
Realized pnl

New position opened

Realized Pnl = 0

New trade for an existing position

Side changed, i.e. long became short or short became long

Realized Pnl = Pnl for the side which was closed Unrealized Pnl for the position is set to 0

Size reduced, i.e. long reduces in size but remains long, or, short reduces in size but remains short

Realized Pnl = (InitialSize - FinalSize) * (TradePrice - LastAvgEntryPrice)

Size increased, i.e. long increases in size but remains long, or, short increases in size but remains short

Realized Pnl = 0

  1. Realized funding calculation for trades

Scenario
Sub-scenario
Realized funding

New position opened

Realized funding = 0

New trade for an existing position

Side changed, i.e. long became short or short became long

Realized funding = Funding accumulated since the last trade Unrealized funding for the corresponding position is set to 0

Size reduced, i.e. long reduces in size but remains long, or, short reduces in size but remains short

Realized funding = Funding accumulated since the last trade Unrealized funding for the corresponding position is set to 0

Size increased, i.e. long increases in size but remains long, or short increases in size but remains short

Realized funding = Funding accumulated since the last trade Unrealized funding for the corresponding position is set to 0

  1. Fees calculation for orders

The fee displayed for orders covers the total fee incurred from placing the order to creating the position (There is a delay between aforementioned events due to the delayed order mechanism of DexToro Liquidity)

Type of order
Fees calculation

Standard order

Fees = keeper fee + execution fee

Limit order

Fees = limit order fees + keeper fee + execution fee

  1. Unrealized funding calculation for positions

Funding shown in positions tab is the unrealized funding accrued for the position since the last trade placed by the user. P.S.: There is a cron which updates the unrealized funding for a position every 3 minutes, so the unrealized funding shown is not always accurate.

  1. Realized Pnl calculation for liquidations

Realized Pnl for a liquidation can be seen in the History tab. A new trade is created with side field set to Liquidation. Realized pnl for a liquidation trade is set to the total margin present in the market when the position was liquidated.

Last updated