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

Method parse_market

python/ccxt/grvt.py:657–748  ·  view source on GitHub ↗
(self, market)

Source from the content-addressed store, hash-verified

655 return self.parse_markets(result)
656
657 def parse_market(self, market) -> Market:
658 #
659 # {
660 # "instrument": "BTC_USDT_Perp",
661 # "instrument_hash": "0x030501",
662 # "base": "BTC",
663 # "quote": "USDT",
664 # "kind": "PERPETUAL",
665 # "venues": [
666 # "ORDERBOOK",
667 # "RFQ"
668 # ],
669 # "settlement_period": "PERPETUAL",
670 # "base_decimals": 9,
671 # "quote_decimals": 6,
672 # "tick_size": "0.1",
673 # "min_size": "0.001",
674 # "create_time": "1768040726362828205",
675 # "max_position_size": "1000.0",
676 # "funding_interval_hours": 8,
677 # "adjusted_funding_rate_cap": "0.3",
678 # "adjusted_funding_rate_floor": "-0.3",
679 # "min_notional": "100.0"
680 # }
681 #
682 marketId = self.safe_string(market, 'instrument')
683 baseId = self.safe_string(market, 'base')
684 quoteId = self.safe_string(market, 'quote')
685 settleId = quoteId
686 base = self.safe_currency_code(baseId)
687 quote = self.safe_currency_code(quoteId)
688 settle = self.safe_currency_code(settleId)
689 symbol = base + '/' + quote + ':' + settle
690 type = None
691 typeRaw = self.safe_string(market, 'kind')
692 if typeRaw == 'PERPETUAL':
693 type = 'swap'
694 isSpot = (type == 'spot')
695 isSwap = (type == 'swap')
696 isFuture = (type == 'future')
697 isContract = isSwap or isFuture
698 return {
699 'id': marketId,
700 'symbol': symbol,
701 'base': base,
702 'quote': quote,
703 'settle': settle,
704 'baseId': baseId,
705 'quoteId': quoteId,
706 'settleId': settleId,
707 'type': type,
708 'spot': isSpot,
709 'margin': False,
710 'swap': isSwap,
711 'future': isFuture,
712 'option': False,
713 'active': None, # todo: ask support to add
714 'contract': isContract,

Callers

nothing calls this directly

Calls 6

safe_stringMethod · 0.80
parse_numberMethod · 0.80
safe_numberMethod · 0.80
parse_precisionMethod · 0.80
safe_integer_productMethod · 0.80
safe_currency_codeMethod · 0.45

Tested by

no test coverage detected