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

Method set_leverage

python/ccxt/async_support/ascendex.py:2972–2999  ·  view source on GitHub ↗

set the level of leverage for a market https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage :param float leverage: the rate of leverage :param str symbol: unified market symbol :param dict [params]: extra parameters specific to t

(self, leverage: int, symbol: Str = None, params={})

Source from the content-addressed store, hash-verified

2970 return await self.modify_margin_helper(symbol, amount, 'add', params)
2971
2972 async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
2973 """
2974 set the level of leverage for a market
2975
2976 https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
2977
2978 :param float leverage: the rate of leverage
2979 :param str symbol: unified market symbol
2980 :param dict [params]: extra parameters specific to the exchange API endpoint
2981 :returns dict: response from the exchange
2982 """
2983 if symbol is None:
2984 raise ArgumentsRequired(self.id + ' setLeverage() requires a symbol argument')
2985 if (leverage < 1) or (leverage > 100):
2986 raise BadRequest(self.id + ' leverage should be between 1 and 100')
2987 await self.load_markets()
2988 await self.load_accounts()
2989 market = self.market(symbol)
2990 if not market['swap']:
2991 raise BadSymbol(self.id + ' setLeverage() supports swap contracts only')
2992 account = self.safe_dict(self.accounts, 0, {})
2993 accountGroup = self.safe_string(account, 'id')
2994 request = {
2995 'account-group': accountGroup,
2996 'symbol': market['id'],
2997 'leverage': leverage,
2998 }
2999 return await self.v2PrivateAccountGroupPostFuturesLeverage(self.extend(request, params))
3000
3001 async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
3002 """

Callers

nothing calls this directly

Calls 10

ArgumentsRequiredClass · 0.90
BadRequestClass · 0.90
BadSymbolClass · 0.90
safe_dictMethod · 0.80
safe_stringMethod · 0.80
load_marketsMethod · 0.45
load_accountsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected