-2
I’m trying to use the formula mentioned on Binance for Futures USD-M PNL & ROE but not getting the first part correctly (PNL).
Link to the guide: How to Calculate Profit and Loss for Futures Contracts | Binance Support
Formula to get Unrealized PNL: Unrealized PNL = position size * direction of order * (mark price - entry price)
Binance app:
My attempt:
quantity = 6.645
entry_price = 221.230
exit_price = 221.470
unrealized_pnl = quantity * -1 * (exit_price - entry_price)
print(f"Unrealized PNL is: {unrealized_pnl}")
Output: Unrealized PNL is: -1.5948000000000604
What am I missing?
EDIT: I got the PNL working, I think. I used the following code:
unrealized_pnl = (mark_price - entry_price) * 0.03
Still no idea how to get ROE…
Formula:
> ROE% =Unrealized PNL in USDT / entry margin = ( ( mark Price - entry Price ) * direction of order * size ) / (position_amount * contract_multiplier * mark_price* IMR
What to enter for contract_multiplier? What is “size” and “position_amount”? How do they differ?
Sory but, have you solved this question?
positions = client.futures_position_information()
for position in positions:
if symbol and symbol == position['symbol']:
etc....
# Data trade
symbol = position['symbol']
entry_price = float(position['entryPrice'])
mark_price = get_mark_price(symbol)
position_amount = float(position['positionAmt'])
# Verifica se a posição é comprada ou vendida
if position_amount > 0: #LONG
#side = OrderSide.BUY
direction = 1
else:#SHORT
#side = OrderSide.SELL
direction = -1
#direction = 1 if position['positionSide'] == 'LONG' else -1
leverage = int(position['leverage'])
# Cálculo do ROE
contract_multiplier = 1 # ou outro valor dependendo do par de negociação
imr = 1 / leverage
unrealized_pnl = position_amount * direction * (mark_price - entry_price) * contract_multiplier
entry_margin = position_amount * contract_multiplier * mark_price * imr
roe = unrealized_pnl / entry_margin * 100
log_print(f"Par {symbol} Tem ROE {roe}%")
Contract multiplier represents the value of a contract.
USD-M
Each futures contract specifies the base asset’s quantity delivered for a single contract, also known as “Contract Unit”. For instance, BTC/USDT, ETH/USDT, and BCH/USDT futures contracts represent only one unit of its respective base asset, similar to spot markets.
Coin-M
Each BTC futures contract represents 100 USD, while each ETH futures contract represents 10 USD. For example, 1,000 USD of BTCUSD Quarterly 1225 equals 100 USD x 10 contracts, and 1,000 USD of ETHUSD Quarterly 1225 equals 10 USD x 100 contracts.
I did not quite understand. Can you provide more examples for USD-M, please?
USD-M contract multiplier is always 1.