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

Method fetch_positions

python/ccxt/async_support/bitget.py:7575–7755  ·  view source on GitHub ↗

fetch all open positions https://www.bitget.com/api-doc/contract/position/get-all-position https://www.bitget.com/api-doc/contract/position/Get-History-Position https://www.bitget.com/api-doc/uta/trade/Get-Position :param str[] [symbols]: list of unified ma

(self, symbols: Strings = None, params={})

Source from the content-addressed store, hash-verified

7573 return self.parse_position(first, market)
7574
7575 async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
7576 """
7577 fetch all open positions
7578
7579 https://www.bitget.com/api-doc/contract/position/get-all-position
7580 https://www.bitget.com/api-doc/contract/position/Get-History-Position
7581 https://www.bitget.com/api-doc/uta/trade/Get-Position
7582
7583 :param str[] [symbols]: list of unified market symbols
7584 :param dict [params]: extra parameters specific to the exchange API endpoint
7585 :param str [params.marginCoin]: the settle currency of the positions, needs to match the productType
7586 :param str [params.productType]: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
7587 :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
7588 :param boolean [params.useHistoryEndpoint]: default False, when True will use the historic endpoint to fetch positions
7589 :param str [params.method]: either(default) 'privateMixGetV2MixPositionAllPosition', 'privateMixGetV2MixPositionHistoryPosition', or 'privateUtaGetV3PositionCurrentPosition'
7590 :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
7591 :returns dict[]: a list of `position structure <https://docs.ccxt.com/?id=position-structure>`
7592 """
7593 await self.load_markets()
7594 paginate = False
7595 paginate, params = self.handle_option_and_params(params, 'fetchPositions', 'paginate')
7596 if paginate:
7597 return await self.fetch_paginated_call_cursor('fetchPositions', None, None, None, params, 'endId', 'idLessThan')
7598 method = None
7599 useHistoryEndpoint = self.safe_bool(params, 'useHistoryEndpoint', False)
7600 if useHistoryEndpoint:
7601 method = 'privateMixGetV2MixPositionHistoryPosition'
7602 else:
7603 method, params = self.handle_option_and_params(params, 'fetchPositions', 'method', 'privateMixGetV2MixPositionAllPosition')
7604 market = None
7605 if symbols is not None:
7606 first = self.safe_string(symbols, 0)
7607 # symbols can be None or []
7608 if first is not None:
7609 market = self.market(first)
7610 productType = None
7611 productType, params = self.handle_product_type_and_params(market, params)
7612 request = {}
7613 response = None
7614 isHistory = False
7615 uta = None
7616 uta, params = self.handle_option_and_params(params, 'fetchPositions', 'uta', False)
7617 if uta:
7618 request['category'] = productType
7619 response = await self.privateUtaGetV3PositionCurrentPosition(self.extend(request, params))
7620 elif method == 'privateMixGetV2MixPositionAllPosition':
7621 marginCoin = self.safe_string(params, 'marginCoin', 'USDT')
7622 if market is not None:
7623 marginCoin = market['settleId']
7624 elif productType == 'USDT-FUTURES':
7625 marginCoin = 'USDT'
7626 elif productType == 'USDC-FUTURES':
7627 marginCoin = 'USDC'
7628 elif productType == 'SUSDT-FUTURES':
7629 marginCoin = 'SUSDT'
7630 elif productType == 'SUSDC-FUTURES':
7631 marginCoin = 'SUSDC'
7632 elif (productType == 'SCOIN-FUTURES') or (productType == 'COIN-FUTURES'):

Callers

nothing calls this directly

Calls 15

parse_positionMethod · 0.95
ArgumentsRequiredClass · 0.90
safe_boolMethod · 0.80
safe_stringMethod · 0.80
safe_dictMethod · 0.80
safe_listMethod · 0.80
market_symbolsMethod · 0.80

Tested by

no test coverage detected