def sell_market(symbol, quantity): order = client.sell_market(symbol, quantity) if 'msg' in order: Messages.get(order['msg']) return order
def sell_limit(symbol, quantity, sell_price): order = client.sell_limit(symbol, quantity, sell_price) if 'msg' in order: Messages.get(order['msg']) return order
def buy_limit(symbol, quantity, buyPrice): order = client.buy_limit(symbol, quantity, buyPrice) if 'msg' in order: Messages.get(order['msg']) # Buy order created. return order['orderId']
def get_order_status(symbol, orderId): try: order = client.query_order(symbol, orderId) if 'msg' in order: Messages.get(order['msg']) return order['status'] except Exception as e: print('get_order_status Exception: %s' % e) return None
def get_order(symbol, orderId): try: order = client.query_order(symbol, orderId) if 'msg' in order: #import ipdb; ipdb.set_trace() Messages.get(order['msg']) # TODO return False return order except Exception as e: print('get_order Exception: %s' % e) return False
def cancel_order(symbol, orderId): try: order = client.cancel(symbol, orderId) if 'msg' in order: Messages.get(order['msg']) print('Profit loss, called order, %s' % (orderId)) return True except Exception as e: print('cancel_order Exception: %s' % e) return False