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

Method fetch_margin_mode

python/ccxt/async_support/binance.py:13031–13069  ·  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

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