closes open positions for a market https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-close-position :param str symbol: Unified CCXT market symbol :param str [side]: not used by cryptocom.closePositions :param dict [params]: extra param
(self, symbol: str, side: OrderSide = None, params={})
| 3190 | return returnString |
| 3191 | |
| 3192 | def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order: |
| 3193 | """ |
| 3194 | closes open positions for a market |
| 3195 | |
| 3196 | https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-close-position |
| 3197 | |
| 3198 | :param str symbol: Unified CCXT market symbol |
| 3199 | :param str [side]: not used by cryptocom.closePositions |
| 3200 | :param dict [params]: extra parameters specific to the okx api endpoint |
| 3201 | |
| 3202 | EXCHANGE SPECIFIC PARAMETERS |
| 3203 | :param str [params.type]: LIMIT or MARKET |
| 3204 | :param number [params.price]: for limit orders only |
| 3205 | :returns dict[]: `A list of position structures <https://docs.ccxt.com/?id=position-structure>` |
| 3206 | """ |
| 3207 | self.load_markets() |
| 3208 | market = self.market(symbol) |
| 3209 | request = { |
| 3210 | 'instrument_name': market['id'], |
| 3211 | 'type': 'MARKET', |
| 3212 | } |
| 3213 | type = self.safe_string_upper(params, 'type') |
| 3214 | price = self.safe_string(params, 'price') |
| 3215 | if type is not None: |
| 3216 | request['type'] = type |
| 3217 | if price is not None: |
| 3218 | request['price'] = self.price_to_precision(market['symbol'], price) |
| 3219 | response = self.v1PrivatePostPrivateClosePosition(self.extend(request, params)) |
| 3220 | # |
| 3221 | # { |
| 3222 | # "id" : 1700830813298, |
| 3223 | # "method" : "private/close-position", |
| 3224 | # "code" : 0, |
| 3225 | # "result" : { |
| 3226 | # "client_oid" : "179a909d-5614-655b-0d0e-9e85c9a25c85", |
| 3227 | # "order_id" : "6142909897021751347" |
| 3228 | # } |
| 3229 | # } |
| 3230 | # |
| 3231 | result = self.safe_dict(response, 'result') |
| 3232 | return self.parse_order(result, market) |
| 3233 | |
| 3234 | def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface: |
| 3235 | """ |
nothing calls this directly
no test coverage detected