* @method * @name bitget#fetchPositions * @description fetch all open positions * @see https://www.bitget.com/api-doc/contract/position/get-all-position * @see https://www.bitget.com/api-doc/contract/position/Get-History-Position * @see https://www.bitget.com/api-doc/uta/tra
(symbols: Strings = undefined, params = {})
| 7955 | * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure} |
| 7956 | */ |
| 7957 | async fetchPositions (symbols: Strings = undefined, params = {}): Promise<Position[]> { |
| 7958 | await this.loadMarkets (); |
| 7959 | let paginate = false; |
| 7960 | [ paginate, params ] = this.handleOptionAndParams (params, 'fetchPositions', 'paginate'); |
| 7961 | if (paginate) { |
| 7962 | return await this.fetchPaginatedCallCursor ('fetchPositions', undefined, undefined, undefined, params, 'endId', 'idLessThan') as Position[]; |
| 7963 | } |
| 7964 | let method: Str = undefined; |
| 7965 | const useHistoryEndpoint = this.safeBool (params, 'useHistoryEndpoint', false); |
| 7966 | if (useHistoryEndpoint) { |
| 7967 | method = 'privateMixGetV2MixPositionHistoryPosition'; |
| 7968 | } else { |
| 7969 | [ method, params ] = this.handleOptionAndParams (params, 'fetchPositions', 'method', 'privateMixGetV2MixPositionAllPosition'); |
| 7970 | } |
| 7971 | let market: Market = undefined; |
| 7972 | if (symbols !== undefined) { |
| 7973 | const first = this.safeString (symbols, 0); |
| 7974 | // symbols can be undefined or [] |
| 7975 | if (first !== undefined) { |
| 7976 | market = this.market (first); |
| 7977 | } |
| 7978 | } |
| 7979 | let productType: Str = undefined; |
| 7980 | [ productType, params ] = this.handleProductTypeAndParams (market, params); |
| 7981 | const request: Dict = {}; |
| 7982 | let response = undefined; |
| 7983 | let isHistory = false; |
| 7984 | let uta = undefined; |
| 7985 | [ uta, params ] = this.handleOptionAndParams (params, 'fetchPositions', 'uta', false); |
| 7986 | if (uta) { |
| 7987 | request['category'] = productType; |
| 7988 | response = await this.privateUtaGetV3PositionCurrentPosition (this.extend (request, params)); |
| 7989 | } else if (method === 'privateMixGetV2MixPositionAllPosition') { |
| 7990 | let marginCoin = this.safeString (params, 'marginCoin', 'USDT'); |
| 7991 | if (market !== undefined) { |
| 7992 | marginCoin = market['settleId']; |
| 7993 | } else if (productType === 'USDT-FUTURES') { |
| 7994 | marginCoin = 'USDT'; |
| 7995 | } else if (productType === 'USDC-FUTURES') { |
| 7996 | marginCoin = 'USDC'; |
| 7997 | } else if (productType === 'SUSDT-FUTURES') { |
| 7998 | marginCoin = 'SUSDT'; |
| 7999 | } else if (productType === 'SUSDC-FUTURES') { |
| 8000 | marginCoin = 'SUSDC'; |
| 8001 | } else if ((productType === 'SCOIN-FUTURES') || (productType === 'COIN-FUTURES')) { |
| 8002 | if (marginCoin === undefined) { |
| 8003 | throw new ArgumentsRequired (this.id + ' fetchPositions() requires a marginCoin parameter that matches the productType'); |
| 8004 | } |
| 8005 | } |
| 8006 | request['marginCoin'] = marginCoin; |
| 8007 | request['productType'] = productType; |
| 8008 | response = await this.privateMixGetV2MixPositionAllPosition (this.extend (request, params)); |
| 8009 | } else { |
| 8010 | isHistory = true; |
| 8011 | if (market !== undefined) { |
| 8012 | request['symbol'] = market['id']; |
| 8013 | } |
| 8014 | request['productType'] = productType; |
nothing calls this directly
no test coverage detected