INNER CODE UNIT · Python

bid

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

        bid = map(lambda x: (float(x[0]), x[1]), sorted(filter(lambda x: x[1] > 0, market_depth.items()), key=lambda x: -float(x[0])))
        ask = map(lambda x: (float(x[0]), x[1]), sorted(filter(lambda x: x[1] < 0, market_depth.items()), key=lambda x: float(x[0])))
        bid = pd.DataFrame(bid, columns=['price', 'size'])
        ask = pd.DataFrame(ask, columns=['price', 'size'])
        mid = (bid['price'][0] + ask['price'][0]) / 2.0

        buy = bid[bid['price'] > mid * (1 - depth)]['size'].sum()
        sell = ask[ask['price'] > mid * (1 + depth)]['size'].sum()
        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)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…