MCPcopy Create free account
hub / github.com/ccxt/ccxt / close_all_positions

Method close_all_positions

python/ccxt/bitget.py:9939–9998  ·  view source on GitHub ↗

closes all open positions for a market type https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position https://www.bitget.com/api-doc/uta/trade/Close-All-Positions :param dict [params]: extra parameters specific to the exchange API endpoint :param s

(self, params={})

Source from the content-addressed store, hash-verified

9937 return self.parse_order(order[0], market)
9938
9939 def close_all_positions(self, params={}) -> List[Position]:
9940 """
9941 closes all open positions for a market type
9942
9943 https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
9944 https://www.bitget.com/api-doc/uta/trade/Close-All-Positions
9945
9946 :param dict [params]: extra parameters specific to the exchange API endpoint
9947 :param str [params.productType]: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
9948 :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
9949 :returns dict[]: A list of `position structures <https://docs.ccxt.com/?id=position-structure>`
9950 """
9951 self.load_markets()
9952 request = {}
9953 productType = None
9954 uta = None
9955 response = None
9956 productType, params = self.handle_product_type_and_params(None, params)
9957 uta, params = self.handle_option_and_params(params, 'closeAllPositions', 'uta', False)
9958 if uta:
9959 request['category'] = productType
9960 response = self.privateUtaPostV3TradeClosePositions(self.extend(request, params))
9961 #
9962 # {
9963 # "code": "00000",
9964 # "msg": "success",
9965 # "requestTime": 1751020218384,
9966 # "data": {
9967 # "list": [
9968 # {
9969 # "orderId": "1322440134099320832",
9970 # "clientOid": "1322440134099320833"
9971 # }
9972 # ]
9973 # }
9974 # }
9975 #
9976 else:
9977 request['productType'] = productType
9978 response = self.privateMixPostV2MixOrderClosePositions(self.extend(request, params))
9979 #
9980 # {
9981 # "code": "00000",
9982 # "msg": "success",
9983 # "requestTime": 1702975017017,
9984 # "data": {
9985 # "successList": [
9986 # {
9987 # "orderId": "1120923953904893955",
9988 # "clientOid": "1120923953904893956"
9989 # }
9990 # ],
9991 # "failureList": [],
9992 # "result": False
9993 # }
9994 # }
9995 #
9996 data = self.safe_value(response, 'data', {})

Callers

nothing calls this directly

Calls 9

safe_valueMethod · 0.80
safe_list_2Method · 0.80
load_marketsMethod · 0.45
extendMethod · 0.45
parse_positionsMethod · 0.45

Tested by

no test coverage detected