python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

Futures USDM - Unrealized Profit doesn't match.

Open kevinyin9 opened this issue 4 years ago • 2 comments

I am trading a specific pair multiple times and record the orderId.

Then, use these orderIds to get entry price (avgPrice) to calculate the unrealized profit.

My calculation formula is: (currentPrice - avgPrice) * positionAmt * positionSide

But the calculation result does not match the unRealizedProfit in futures_position_information().

No matter the currentPrice is markPrice or indexPrice, the results are unmatched. Sometimes the calculation results are even different from the positive and negative signs.

If you need, I can give some detail example.

Environment (please complete the following information):

  • Python version: 3.8.5
  • OS: Mac
  • python-binance version: 1.0.12

kevinyin9 avatar Nov 29 '21 09:11 kevinyin9

use

`def get_profit(price,current,qty, side ):

if side == 'BUY':

    profit = (current - price) * qty

if side == 'SELL':

    profit = (price - current) * qty


return profit

`

Aarron-shaw avatar Dec 11 '21 01:12 Aarron-shaw

Thanks for replying.

But in my formula: (currentPrice - avgPrice) * positionAmt * positionSide.

I’ve already considered the position side, which would be 1 if it is buyside else -1.

kevinyin9 avatar Dec 11 '21 02:12 kevinyin9