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

Method fetch_leverages

python/ccxt/binance.py:11027–11066  ·  view source on GitHub ↗

fetch the set leverage for all markets https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2 https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information https://de

(self, symbols: Strings = None, params={})

Source from the content-addressed store, hash-verified

11025 return response
11026
11027 def fetch_leverages(self, symbols: Strings = None, params={}) -> Leverages:
11028 """
11029 fetch the set leverage for all markets
11030
11031 https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
11032 https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information
11033 https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
11034 https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
11035 https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
11036
11037 :param str[] [symbols]: a list of unified market symbols
11038 :param dict [params]: extra parameters specific to the exchange API endpoint
11039 :param str [params.subType]: "linear" or "inverse"
11040 :returns dict: a list of `leverage structures <https://docs.ccxt.com/?id=leverage-structure>`
11041 """
11042 self.load_markets()
11043 self.load_leverage_brackets(False, params)
11044 type = None
11045 type, params = self.handle_market_type_and_params('fetchLeverages', None, params)
11046 subType = None
11047 subType, params = self.handle_sub_type_and_params('fetchLeverages', None, params, 'linear')
11048 isPortfolioMargin = None
11049 isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchLeverages', 'papi', 'portfolioMargin', False)
11050 response = None
11051 if self.is_linear(type, subType):
11052 if isPortfolioMargin:
11053 response = self.papiGetUmAccount(params)
11054 else:
11055 response = self.fapiPrivateGetSymbolConfig(params)
11056 elif self.is_inverse(type, subType):
11057 if isPortfolioMargin:
11058 response = self.papiGetCmAccount(params)
11059 else:
11060 response = self.dapiPrivateGetAccount(params)
11061 else:
11062 raise NotSupported(self.id + ' fetchLeverages() supports linear and inverse contracts only')
11063 leverages = self.safe_list(response, 'positions', [])
11064 if isinstance(response, list):
11065 leverages = response
11066 return self.parse_leverages(leverages, symbols, 'symbol')
11067
11068 def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
11069 marketId = self.safe_string(leverage, 'symbol')

Callers

nothing calls this directly

Calls 14

is_linearMethod · 0.95
papiGetUmAccountMethod · 0.95
is_inverseMethod · 0.95
papiGetCmAccountMethod · 0.95
dapiPrivateGetAccountMethod · 0.95
NotSupportedClass · 0.90
safe_listMethod · 0.80
parse_leveragesMethod · 0.80

Tested by

no test coverage detected