From 97ec92af32246a307dae3fe5d385de0326f8c6dd Mon Sep 17 00:00:00 2001 From: Muhammad Zaeem Nasir <53820312+mzaeemnasir@users.noreply.github.com> Date: Wed, 2 Apr 2025 03:43:20 +0100 Subject: [PATCH 1/2] Update client.py Add close-all-postions endpoint that was missing. --- pybitget/client.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pybitget/client.py b/pybitget/client.py index a1be566..f3ee7ed 100644 --- a/pybitget/client.py +++ b/pybitget/client.py @@ -1179,6 +1179,22 @@ def mix_cp_close_position(self, symbol, trackingNo): else: logger.error("pls check args") return False + + def mix_cp_close_all_positions(self, productType): + """ + Trader Close All Positions: https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position + Limit + Limit rule: 1 times/1s (uid) + Required: productType + :return: + """ + params = {} + if productType: + params["productType"] = productType + return self._request_with_params(POST, MIX_ORDER_V1_URL + '/close-all-positions', params) + else: + logger.error("pls check args") + return False def mix_cp_modify_tpsl(self, symbol, trackingNo, stopProfitPrice=None, stopLossPrice=None): """ From c64ac5848091866d88edbe9defc72bc95a75dda9 Mon Sep 17 00:00:00 2001 From: Muhammad Zaeem Nasir <53820312+mzaeemnasir@users.noreply.github.com> Date: Fri, 19 Sep 2025 00:02:09 +0100 Subject: [PATCH 2/2] Enhance mix_cp_close_all_positions with type hinting --- pybitget/client.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pybitget/client.py b/pybitget/client.py index f3ee7ed..7df8b62 100644 --- a/pybitget/client.py +++ b/pybitget/client.py @@ -1180,21 +1180,21 @@ def mix_cp_close_position(self, symbol, trackingNo): logger.error("pls check args") return False - def mix_cp_close_all_positions(self, productType): + def mix_cp_close_all_positions(self, productType: str): """ Trader Close All Positions: https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position Limit Limit rule: 1 times/1s (uid) Required: productType - :return: + :param productType: The product type for closing positions + :return: Response from the API + :raises ValueError: If productType is not provided or is empty """ - params = {} - if productType: - params["productType"] = productType - return self._request_with_params(POST, MIX_ORDER_V1_URL + '/close-all-positions', params) - else: - logger.error("pls check args") - return False + if not productType: + raise ValueError("Parameter `productType` is required and cannot be empty") + + params = {"productType": productType} + return self._request_with_params(POST, MIX_ORDER_V1_URL + '/close-all-positions', params) def mix_cp_modify_tpsl(self, symbol, trackingNo, stopProfitPrice=None, stopLossPrice=None): """