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

Method parse_market

python/ccxt/hyperliquid.py:944–1046  ·  view source on GitHub ↗
(self, market: dict)

Source from the content-addressed store, hash-verified

942 return markets
943
944 def parse_market(self, market: dict) -> Market:
945 #
946 # {
947 # "maxLeverage": "50",
948 # "name": "ETH",
949 # "onlyIsolated": False,
950 # "szDecimals": "4",
951 # "dayNtlVlm": "1709813.11535",
952 # "funding": "0.00004807",
953 # "impactPxs": [
954 # "2369.3",
955 # "2369.6"
956 # ],
957 # "markPx": "2369.6",
958 # "midPx": "2369.45",
959 # "openInterest": "1815.4712",
960 # "oraclePx": "2367.3",
961 # "premium": "0.00090821",
962 # "prevDayPx": "2381.5"
963 # "collateralToken": "0" hip3 tokens only
964 # }
965 #
966 collateralTokenCode = self.safe_string(market, 'collateralTokenName')
967 quoteId = 'USDC' if (collateralTokenCode is None) else collateralTokenCode
968 settleId = 'USDC' if (collateralTokenCode is None) else collateralTokenCode
969 baseName = self.safe_string(market, 'name')
970 base = self.safe_currency_code(baseName)
971 base = base.replace(':', '-') # handle hip3 tokens and converts from like flx:crcl to FLX-CRCL
972 quote = self.safe_currency_code(quoteId)
973 baseId = self.safe_string(market, 'baseId')
974 settle = self.safe_currency_code(settleId)
975 symbol = base + '/' + quote
976 contract = True
977 swap = True
978 if contract:
979 if swap:
980 symbol = symbol + ':' + settle
981 fees = self.safe_dict(self.fees, 'swap', {})
982 taker = self.safe_number(fees, 'taker')
983 maker = self.safe_number(fees, 'maker')
984 amountPrecisionStr = self.safe_string(market, 'szDecimals')
985 amountPrecision = int(amountPrecisionStr)
986 price = self.safe_number(market, 'markPx', 0)
987 pricePrecision = 0
988 if price is not None:
989 pricePrecision = self.calculate_price_precision(price, amountPrecision, 6)
990 pricePrecisionStr = self.number_to_string(pricePrecision)
991 isDelisted = self.safe_bool(market, 'isDelisted')
992 active = True
993 if isDelisted is not None:
994 active = not isDelisted
995 return self.safe_market_structure({
996 'id': baseId,
997 'symbol': symbol,
998 'base': base,
999 'quote': quote,
1000 'settle': settle,
1001 'baseId': baseId,

Callers

nothing calls this directly

Calls 11

safe_stringMethod · 0.80
replaceMethod · 0.80
safe_dictMethod · 0.80
safe_numberMethod · 0.80
safe_boolMethod · 0.80
safe_market_structureMethod · 0.80
parse_numberMethod · 0.80
parse_precisionMethod · 0.80
safe_integerMethod · 0.80
safe_currency_codeMethod · 0.45

Tested by

no test coverage detected