Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for batch cancelling by client order ids #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions huobi/client/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,34 @@ def cancel_order(self, symbol, order_id):
from huobi.service.trade.post_cancel_order import PostCancelOrderService
return PostCancelOrderService(params).request(**self.__kwargs)

def cancel_orders(self, symbol, order_id_list)->BatchCancelResult:
def cancel_orders(self, symbol, order_id_list=[], client_order_id_list=[])->BatchCancelResult:
"""
Submit cancel request for cancelling multiple orders.
Either order_id_list or client_order_id_list must be filled.

:param symbol: The symbol, like "btcusdt". (mandatory)
:param order_id_list: The list of order id. the max size is 50. (mandatory)
:param order_id_list: The list of order id. the max size is 50. (optional)
:param client_order_id_list: The list of client order id. the max size is 50. (optional)
:return: No return
"""
check_symbol(symbol)
check_should_not_none(order_id_list, "order_id_list")
check_list(order_id_list, 1, 50, "order_id_list")
check_should_not_none(client_order_id_list, "client_order_id_list")
# check_list(order_id_list, 0, 50, "order_id_list")
# check_list(client_order_id_list, 0, 50, "client_order_id_list")
check_list(order_id_list + client_order_id_list, 1, 50, "order_id_list together with client_order_id_list")

string_list = list()
for order_id in order_id_list:
string_list.append(str(order_id))

client_string_list = list()
for order_id in client_order_id_list:
client_string_list.append(str(order_id))

params = {
"order-ids" : string_list
"order-ids" : string_list,
"client-order-ids" : client_order_id_list,
}

from huobi.service.trade.post_batch_cancel_order import PostBatchCancelOrderService
Expand Down