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

Method fetch_default_markets

python/ccxt/async_support/bitget.py:1974–2214  ·  view source on GitHub ↗
(self, params)

Source from the content-addressed store, hash-verified

1972 return await self.fetch_default_markets(params)
1973
1974 async def fetch_default_markets(self, params) -> List[Market]:
1975 types = None
1976 fetchMarketsOptions = self.safe_dict(self.options, 'fetchMarkets')
1977 defaultMarkets = ['spot', 'swap']
1978 if fetchMarketsOptions is not None:
1979 types = self.safe_list(fetchMarketsOptions, 'types', defaultMarkets)
1980 else:
1981 # for backward-compatibility
1982 types = self.safe_list(self.options, 'fetchMarkets', defaultMarkets)
1983 promises = []
1984 fetchMargins = False
1985 for i in range(0, len(types)):
1986 type = types[i]
1987 if (type == 'swap') or (type == 'future'):
1988 subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES', 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
1989 for j in range(0, len(subTypes)):
1990 promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
1991 'productType': subTypes[j],
1992 })))
1993 elif type == 'spot':
1994 promises.append(self.publicSpotGetV2SpotPublicSymbols(params))
1995 fetchMargins = True
1996 promises.append(self.publicMarginGetV2MarginCurrencies(params))
1997 else:
1998 raise NotSupported(self.id + ' does not support ' + type + ' market')
1999 results = await asyncio.gather(*promises)
2000 markets = []
2001 self.options['crossMarginPairsData'] = []
2002 self.options['isolatedMarginPairsData'] = []
2003 for i in range(0, len(results)):
2004 res = self.safe_dict(results, i)
2005 data = self.safe_list(res, 'data', [])
2006 firstData = self.safe_dict(data, 0, {})
2007 isBorrowable = self.safe_bool(firstData, 'isBorrowable')
2008 if fetchMargins and isBorrowable is not None:
2009 keysList = list(self.index_by(data, 'symbol').keys())
2010 self.options['crossMarginPairsData'] = keysList
2011 self.options['isolatedMarginPairsData'] = keysList
2012 else:
2013 markets = self.array_concat(markets, data)
2014 #
2015 # spot
2016 #
2017 # {
2018 # "symbol": "TRXUSDT",
2019 # "baseCoin": "TRX",
2020 # "quoteCoin": "USDT",
2021 # "minTradeAmount": "0",
2022 # "maxTradeAmount": "10000000000",
2023 # "takerFeeRate": "0.002",
2024 # "makerFeeRate": "0.002",
2025 # "pricePrecision": "6",
2026 # "quantityPrecision": "4",
2027 # "quotePrecision": "6",
2028 # "status": "online",
2029 # "minTradeUSDT": "5",
2030 # "buyLimitPriceRatio": "0.05",
2031 # "sellLimitPriceRatio": "0.05"

Callers 1

fetch_marketsMethod · 0.95

Calls 15

reduceMethod · 0.95
NotSupportedClass · 0.90
PreciseClass · 0.90
safe_dictMethod · 0.80
safe_listMethod · 0.80
safe_boolMethod · 0.80
index_byMethod · 0.80
array_concatMethod · 0.80
safe_stringMethod · 0.80
safe_valueMethod · 0.80
in_arrayMethod · 0.80
parse_numberMethod · 0.80

Tested by

no test coverage detected