1

I'm wondering how to calculate a price (per unit) for 1 order that was filled 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 used to calculate the price by taking the cummulativeQuoteQty and divide it by the executedQty, leading to 0.01015332.

But honestly, I've never been quite so sure about that and now I saw that TabTrader displays a price of 0.010187.

So my question now is: how exactly should one proceed if the price were to be used to calculate a profit?

PS. Taking the quantity weighted prices from the trades leads to yet another different value:

ipdb> weigted_price_from_trades = (0.01023100 * 3 + 28 * 0.01014400) / 28.
0.011240178571428573
Ytsen de Boer
  • 121
  • 1
  • 7

0 Answers0