def cancel_all_orders(self): """ Cancels all unmatched orders across all markets. :return: information on the cancellation status of each order. """ date_time_sent = datetime.datetime.utcnow() response = self.request('CancelAllOrders', {}, secure=True) data = self.process_response(response, date_time_sent, 'Orders') return [ parse_cancelled_order(cancel) for cancel in data.get('data', {}).get('Order', []) ] if data.get('data') else []
def cancel_orders_by_market(self, market_ids): """ Cancel all orders on one or more markets on exchange :param market_ids: list of market ids to be cancelled. :type market_ids: list of ints :return: information on the cancellation status of each order. """ params = self.client.secure_types['CancelAllOrdersOnMarketRequest']( _value_1=[{'MarketIds': market} for market in market_ids] ) date_time_sent = datetime.datetime.utcnow() response = self.request('CancelAllOrdersOnMarket', params, secure=True) data = self.process_response(response, date_time_sent, 'Order', error_handler=err_cancel_market) return [parse_cancelled_order(cancel) for cancel in data.get('data', [])] if data.get('data') else []
def cancel_orders(self, order_ids): """ Cancel one or more orders on exchange :param order_ids: list of order ids to be cancelled. :type order_ids: list of ints :return: information on the cancellation status of each order. """ params = self.client.secure_types['CancelOrdersRequest']( _value_1=[{'OrderHandle': order_id} for order_id in order_ids] ) date_time_sent = datetime.datetime.utcnow() response = self.request('CancelOrders', params, secure=True) data = self.process_response(response, date_time_sent, 'Orders') return [ parse_cancelled_order(cancel) for cancel in data.get('data', {}).get('Order', []) ] if data.get('data') else []