Open kevinyin9 opened 2 years ago
use
`def get_profit(price,current,qty, side ):
if side == 'BUY':
profit = (current - price) * qty
if side == 'SELL':
profit = (price - current) * qty
return profit
`
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.
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):