INNER CODE UNIT · Python
order_qty
nkaz001/sample-trading-bot · tradingbot/custom_strategy.py:33
order_qty = order_qty_dollar / float(self.binance_futures.last_price)
logging.info('buy=%f, sell=%f, alpha=%f, threshold=%f, last=%f, order_qty=%f', buy, sell, alpha, threshold,
float(self.binance_futures.last_price), order_qty)
if alpha > threshold and not self.long_position_limit_exceeded():
buy_orders.append({'price': bid['price'][0], 'quantity': order_qty, 'side': "Buy"})
if alpha < -threshold and not self.short_position_limit_exceeded():
sell_orders.append({'price': ask['price'][0], 'quantity': order_qty, 'side': "Sell"})
await self.converge_orders(buy_orders, sell_orders)
except ZeroDivisionError:
# Skip until receiving the last price in WS.
pass
except:
logging.warning('Order error.', exc_info=True)