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

Method fetch_markets_v2

python/ccxt/coinbase.py:1321–1388  ·  view source on GitHub ↗
(self, params={})

Source from the content-addressed store, hash-verified

1319 return self.fetch_markets_v2(params)
1320
1321 def fetch_markets_v2(self, params={}) -> List[Market]:
1322 response = self.fetch_currencies_from_cache(params)
1323 currencies = self.safe_dict(response, 'currencies', {})
1324 exchangeRates = self.safe_dict(response, 'exchangeRates', {})
1325 data = self.safe_list(currencies, 'data', [])
1326 dataById = self.index_by(data, 'id')
1327 rates = self.safe_dict(self.safe_dict(exchangeRates, 'data', {}), 'rates', {})
1328 baseIds = list(rates.keys())
1329 result = []
1330 for i in range(0, len(baseIds)):
1331 baseId = baseIds[i]
1332 base = self.safe_currency_code(baseId)
1333 type = 'fiat' if (baseId in dataById) else 'crypto'
1334 # https://github.com/ccxt/ccxt/issues/6066
1335 if type == 'crypto':
1336 for j in range(0, len(data)):
1337 quoteCurrency = data[j]
1338 quoteId = self.safe_string(quoteCurrency, 'id')
1339 quote = self.safe_currency_code(quoteId)
1340 result.append(self.safe_market_structure({
1341 'id': baseId + '-' + quoteId,
1342 'symbol': base + '/' + quote,
1343 'base': base,
1344 'quote': quote,
1345 'settle': None,
1346 'baseId': baseId,
1347 'quoteId': quoteId,
1348 'settleId': None,
1349 'type': 'spot',
1350 'spot': True,
1351 'margin': False,
1352 'swap': False,
1353 'future': False,
1354 'option': False,
1355 'active': None,
1356 'contract': False,
1357 'linear': None,
1358 'inverse': None,
1359 'contractSize': None,
1360 'expiry': None,
1361 'expiryDatetime': None,
1362 'strike': None,
1363 'optionType': None,
1364 'precision': {
1365 'amount': None,
1366 'price': None,
1367 },
1368 'limits': {
1369 'leverage': {
1370 'min': None,
1371 'max': None,
1372 },
1373 'amount': {
1374 'min': None,
1375 'max': None,
1376 },
1377 'price': {
1378 'min': None,

Callers 1

fetch_marketsMethod · 0.95

Calls 10

safe_dictMethod · 0.80
safe_listMethod · 0.80
index_byMethod · 0.80
safe_stringMethod · 0.80
safe_market_structureMethod · 0.80
safe_numberMethod · 0.80
rangeFunction · 0.50
safe_currency_codeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected