* @method * @name cryptocom#closePositions * @description closes open positions for a market * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-close-position * @param {string} symbol Unified CCXT market symbol * @param {string} [side] not used by
(symbol: string, side: OrderSide = undefined, params = {})
| 3374 | * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/?id=position-structure} |
| 3375 | */ |
| 3376 | async closePosition (symbol: string, side: OrderSide = undefined, params = {}): Promise<Order> { |
| 3377 | await this.loadMarkets (); |
| 3378 | const market = this.market (symbol); |
| 3379 | const request: Dict = { |
| 3380 | 'instrument_name': market['id'], |
| 3381 | 'type': 'MARKET', |
| 3382 | }; |
| 3383 | const type = this.safeStringUpper (params, 'type'); |
| 3384 | const price = this.safeString (params, 'price'); |
| 3385 | if (type !== undefined) { |
| 3386 | request['type'] = type; |
| 3387 | } |
| 3388 | if (price !== undefined) { |
| 3389 | request['price'] = this.priceToPrecision (market['symbol'], price); |
| 3390 | } |
| 3391 | const response = await this.v1PrivatePostPrivateClosePosition (this.extend (request, params)); |
| 3392 | // |
| 3393 | // { |
| 3394 | // "id" : 1700830813298, |
| 3395 | // "method" : "private/close-position", |
| 3396 | // "code" : 0, |
| 3397 | // "result" : { |
| 3398 | // "client_oid" : "179a909d-5614-655b-0d0e-9e85c9a25c85", |
| 3399 | // "order_id" : "6142909897021751347" |
| 3400 | // } |
| 3401 | // } |
| 3402 | // |
| 3403 | const result = this.safeDict (response, 'result'); |
| 3404 | return this.parseOrder (result as Dict, market); |
| 3405 | } |
| 3406 | |
| 3407 | /** |
| 3408 | * @method |
nothing calls this directly
no test coverage detected