I'm wondering how to calculate a price (per unit) for 1 order executed in 2 trades.
The 2 trades (GET / api / v3 / myTrades):
{'commission': '0.00002301',
'commissionAsset': 'BNB',
'id': 536694,
'isBestMatch': True,
'isBuyer': False,
'isMaker': False,
'orderId': 23456244,
'orderListId': -1,
'price': '0.01023100',
'qty': '3.00000000',
'quoteQty': '0.03069300',
'symbol': 'WABIBNB',
'time': 1573580584514},
{'commission': '0.00019020',
'commissionAsset': 'BNB',
'id': 536695,
'isBestMatch': True,
'isBuyer': False,
'isMaker': False,
'orderId': 23456244,
'orderListId': -1,
'price': '0.01014400',
'qty': '25.00000000',
'quoteQty': '0.25360000',
'symbol': 'WABIBNB',
'time': 1573580584514})
The order: (GET / api / v3 / order):
{'clientOrderId': 'vt0wm640c8DFewafYyrqnW',
'cummulativeQuoteQty': '0.28429300',
'executedQty': '28.00000000',
'icebergQty': '0.00000000',
'isWorking': True,
'orderId': 23456244,
'orderListId': -1,
'origQty': '28.00000000',
'origQuoteOrderQty': '0.00000000',
'price': '0.01013600',
'side': 'SELL',
'status': 'FILLED',
'stopPrice': '0.01032200',
'symbol': 'WABIBNB',
'time': 1573580483202,
'timeInForce': 'GTC',
'type': 'STOP_LOSS_LIMIT',
'updateTime': 1573580584514}
I calculated the price with that cummulativeQuoteQty
and divide it by executedQty
, leads to 0.01015332,
But honestly, I was never so sure about that and now I saw that TabTrader was displaying a price of 0.010187,
My question is: How should you proceed exactly if the price should be used for the determination of profits?
PS. Taking the quantity-weighted prices out of the market leads to another value:
ipdb> weigted_price_from_trades = (0.01023100 * 3 + 28 * 0.01014400) / 28.
0.011240178571428573