INNER CODE UNIT · Python

alpha

nkaz001/sample-trading-bot · tradingbot/custom_strategy.py:27

        alpha = buy - sell

        buy_orders = []
        sell_orders = []

        try:
            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:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…