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

Method fetch_margin_mode

python/ccxt/binance.py:13030–13068  ·  view source on GitHub ↗

fetches the margin mode of a specific symbol https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information :param str s

(self, symbol: str, params={})

Source from the content-addressed store, hash-verified

13028 return self.parse_margin_modes(assets, symbols, 'symbol', 'swap')
13029
13030 def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
13031 """
13032 fetches the margin mode of a specific symbol
13033
13034 https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
13035 https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
13036
13037 :param str symbol: unified symbol of the market the order was made in
13038 :param dict [params]: extra parameters specific to the exchange API endpoint
13039 :param str [params.subType]: "linear" or "inverse"
13040 :returns dict: a `margin mode structure <https://docs.ccxt.com/?id=margin-mode-structure>`
13041 """
13042 self.load_markets()
13043 market = self.market(symbol)
13044 subType = None
13045 subType, params = self.handle_sub_type_and_params('fetchMarginMode', market, params)
13046 response = None
13047 if subType == 'linear':
13048 request = {
13049 'symbol': market['id'],
13050 }
13051 response = self.fapiPrivateGetSymbolConfig(self.extend(request, params))
13052 #
13053 # [
13054 # {
13055 # "symbol": "BTCUSDT",
13056 # "marginType": "CROSSED",
13057 # "isAutoAddMargin": "false",
13058 # "leverage": 21,
13059 # "maxNotionalValue": "1000000",
13060 # }
13061 # ]
13062 #
13063 elif subType == 'inverse':
13064 fetchMarginModesResponse = self.fetch_margin_modes([symbol], params)
13065 return fetchMarginModesResponse[symbol]
13066 else:
13067 raise BadRequest(self.id + ' fetchMarginMode() supports linear and inverse subTypes only')
13068 return self.parse_margin_mode(response[0], market)
13069
13070 def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
13071 marketId = self.safe_string(marginMode, 'symbol')

Callers

nothing calls this directly

Calls 8

marketMethod · 0.95
fetch_margin_modesMethod · 0.95
parse_margin_modeMethod · 0.95
BadRequestClass · 0.90
load_marketsMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected