INNER CODE UNIT · Python
open_orders_active
nkaz001/sample-trading-bot · tradingbot/binancefutures.py:34
def open_orders_active(self):
return {order_id: order for order_id, order in self.open_orders_ws.items() if order['status'] in ['PENDING_NEW', 'NEW', 'PARTIALLY_FILLED']}
async def __on_message(self, message):
message = json.loads(message)
logging.debug(message)
data = message['data']
evt = data['e']
if evt == 'listenKeyExpired':
logging.warning('Listen key is expired.')
await self.ws.close()
elif evt == 'ACCOUNT_UPDATE':
account = data['a']
positions = account['P']
for position in positions:
position_side = position['ps']
if 'BOTH' == position_side:
if position['s'].upper() == self.symbol.upper():