Skip to content
Open
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions pybitget/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a python expert, but, couldn't you type the parameter productType like:

def mix_cp_close_all_positions(self, productType: str):

And then you don't need this check?
If this does not work, it would be nice if the log message is more verbose:

logger.error("Parameter `productType` is missing")

Anyways, I suggest raising an exception, that can be handled from the outside, if the API can't work without the productType parameter.

return False

def mix_cp_modify_tpsl(self, symbol, trackingNo, stopProfitPrice=None, stopLossPrice=None):
"""
Expand Down