Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async def exchange_all_positions(self):
- positions = {}
- posicoes = []
- executa = True
- while executa:
- try:
- positions = await self.exchange.private_get_position()
- executa = False
- except Exception as error:
- if await self.trata_erro_exchange(error=error, name=sys._getframe().f_code.co_name):
- break
- except:
- print('Error exception on', sys._getframe().f_code.co_name, sys.exc_info()[0], sys.exc_info()[1])
- break
- #await self.exchange.close()
- if positions:
- for y in positions:
- if y.get('isOpen', False):
- #print(y['breakEvenPrice'], self.dados_user['first_name'])
- side = 'Buy' if y.get('currentQty', 0) > 0 else 'Sell'
- dados = {'symbol': y.get('symbol',None), 'profit': round(y.get('unrealisedRoePcnt',None) * 100,2), 'side': side, 'qty': abs(y.get('currentQty', 0)), 'price': y.get('avgEntryPrice', None), 'type_order': 'open position', 'id_telegram': self.dados_user['id_telegram'], 'id_account': self.dados_user['id'], 'exchange': self.dados_user['exchange'], 'obs':None, 'order_id': 'open position'}
- posicoes.append(dados)
- return {'dados_user':self.dados_user, 'retorno': posicoes, 'error':executa}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement