INNER CODE UNIT · Python

close

nkaz001/sample-trading-bot · tradingbot/binancefutures.py:385

    async def close(self):
        await self.cancel_all_orders()
        self.closed = True
        if self.ws is not None:
            await self.ws.close()
        await self.client.close()
        await asyncio.sleep(1)

    async def __get_marketdepth_snapshot(self):
        data = await self.__curl_binancefutures(verb='GET', path='/v1/depth', query={'symbol': self.symbol, 'limit': 1000})
        l_bid, _ = data['bids'][-1]
        h_ask, _ = data['asks'][-1]
        self.depth = {price: qty for price, qty in self.depth.items() if (price < l_bid and qty > 0) or (price > h_ask and qty < 0)}
        for price, qty in data['bids']:
            self.depth[price] = float(qty)
        for price, qty in data['asks']:
            self.depth[price] = -float(qty)
        lastUpdateId = data['lastUpdateId']

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…