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

Method set_leverage

python/ccxt/xt.py:3922–3964  ·  view source on GitHub ↗

set the level of leverage for a market https://doc.xt.com/#futures_useradjustLeverage :param float leverage: the rate of leverage :param str symbol: unified market symbol :param dict params: extra parameters specific to the xt api endpoint :param st

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

Source from the content-addressed store, hash-verified

3920 return self.safe_string(statuses, status, status)
3921
3922 def set_leverage(self, leverage: int, symbol: Str = None, params={}):
3923 """
3924 set the level of leverage for a market
3925
3926 https://doc.xt.com/#futures_useradjustLeverage
3927
3928 :param float leverage: the rate of leverage
3929 :param str symbol: unified market symbol
3930 :param dict params: extra parameters specific to the xt api endpoint
3931 :param str params['positionSide']: 'LONG' or 'SHORT'
3932 :returns dict: response from the exchange
3933 """
3934 if symbol is None:
3935 raise ArgumentsRequired(self.id + ' setLeverage() requires a symbol argument')
3936 positionSide = self.safe_string(params, 'positionSide')
3937 self.check_required_argument('setLeverage', positionSide, 'positionSide', ['LONG', 'SHORT'])
3938 if (leverage < 1) or (leverage > 125):
3939 raise BadRequest(self.id + ' setLeverage() leverage should be between 1 and 125')
3940 self.load_markets()
3941 market = self.market(symbol)
3942 if not (market['contract']):
3943 raise BadSymbol(self.id + ' setLeverage() supports contract markets only')
3944 request = {
3945 'symbol': market['id'],
3946 'positionSide': positionSide,
3947 'leverage': leverage,
3948 }
3949 subType = None
3950 subType, params = self.handle_sub_type_and_params('setLeverage', market, params)
3951 response: dict
3952 if subType == 'inverse':
3953 response = self.privateInversePostFutureUserV1PositionAdjustLeverage(self.extend(request, params))
3954 else:
3955 response = self.privateLinearPostFutureUserV1PositionAdjustLeverage(self.extend(request, params))
3956 #
3957 # {
3958 # "returnCode": 0,
3959 # "msgInfo": "success",
3960 # "error": null,
3961 # "result": null
3962 # }
3963 #
3964 return response
3965
3966 def add_margin(self, symbol: str, amount: float, params={}):
3967 """

Callers 5

gate-swaps.pyFile · 0.45
example_1Function · 0.45
example_2Function · 0.45

Calls 11

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

Tested by

no test coverage detected