From 8adec7860726e8c7becfdd2872db60af2bfe53d2 Mon Sep 17 00:00:00 2001 From: pucedoteth Date: Mon, 24 Aug 2026 18:11:00 +0200 Subject: [PATCH] fix(rest): send the order identifier params that were declared but dropped query_order (), cancel_order (), get_open_orders () and cancel_batch_order () all accept the parameters that say *which* order to act on, and then build the request without them: def cancel_order (self, symbol, orderId=None, origClientOrderId=None, **kwargs): check_required_parameter (symbol, "symbol") params = {"symbol": symbol, **kwargs} orderId and origClientOrderId are bound to the named parameters, so they can never arrive through **kwargs either - the value is simply discarded. Every one of these calls goes out carrying nothing but symbol, and the API requires "either orderId or origClientOrderId" (either orderIdList or origClientOrderIdList for the batch), so all four fail server-side. There is no way to query, cancel or inspect a specific order through the connector. cancel_batch_order additionally declares both lists as required positionals, so the documented "either ... or ..." call raises TypeError before any request is built, and the lists need to be JSON arrays with no spaces per the API docs: orderIdList=[1234567,2345678] origClientOrderIdList=["my_id_1","my_id_2"] convert_list_to_json_array () in aster/lib/utils.py already produces exactly that and was not referenced anywhere in the package - it is wired up here. Reported for cancel_order in #1. Co-Authored-By: Claude Opus 5 --- aster/rest_api/account.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/aster/rest_api/account.py b/aster/rest_api/account.py index 45e031b..d0d44d7 100644 --- a/aster/rest_api/account.py +++ b/aster/rest_api/account.py @@ -1,5 +1,6 @@ from aster.lib.utils import check_required_parameter from aster.lib.utils import check_required_parameters +from aster.lib.utils import convert_list_to_json_array def change_position_mode(self, dualSidePosition: str, **kwargs): @@ -113,7 +114,12 @@ def query_order(self, symbol: str, orderId: int = None, origClientOrderId: str = """ check_required_parameter(symbol, "symbol") - params = {"symbol": symbol, **kwargs} + params = { + "symbol": symbol, + "orderId": orderId, + "origClientOrderId": origClientOrderId, + **kwargs, + } url_path = "/fapi/v1/order" return self.sign_request("GET", url_path, params) @@ -131,7 +137,12 @@ def cancel_order(self, symbol: str, orderId: int = None, origClientOrderId: str """ check_required_parameter(symbol, "symbol") - params = {"symbol": symbol, **kwargs} + params = { + "symbol": symbol, + "orderId": orderId, + "origClientOrderId": origClientOrderId, + **kwargs, + } url_path = "/fapi/v1/order" return self.sign_request("DELETE", url_path, params) @@ -152,7 +163,7 @@ def cancel_open_orders(self, symbol: str, **kwargs): return self.sign_request("DELETE", url_path, params) -def cancel_batch_order(self, symbol: str, orderIdList: list, origClientOrderIdList: list, **kwargs): +def cancel_batch_order(self, symbol: str, orderIdList: list = None, origClientOrderIdList: list = None, **kwargs): """ | | **Cancel Multiple Orders (TRADE)** @@ -164,7 +175,14 @@ def cancel_batch_order(self, symbol: str, orderIdList: list, origClientOrderIdLi """ check_required_parameter(symbol, "symbol") - params = {"symbol": symbol, **kwargs} + params = { + "symbol": symbol, + # the endpoint takes these as JSON arrays with no spaces, e.g. + # orderIdList=[1234567,2345678] and origClientOrderIdList=["id1","id2"] + "orderIdList": convert_list_to_json_array(orderIdList), + "origClientOrderIdList": convert_list_to_json_array(origClientOrderIdList), + **kwargs, + } url_path = "/fapi/v1/batchOrders" return self.sign_request("DELETE", url_path, params) @@ -198,7 +216,12 @@ def get_open_orders(self, symbol: str, orderId: int = None, origClientOrderId: s """ check_required_parameter(symbol, "symbol") - params = {"symbol": symbol, **kwargs} + params = { + "symbol": symbol, + "orderId": orderId, + "origClientOrderId": origClientOrderId, + **kwargs, + } url_path = "/fapi/v1/openOrder" return self.sign_request("GET", url_path, params)