exchange.get_max_leverage changed variable names, made more effecient

This commit is contained in:
Sam Germain 2022-01-31 04:47:52 -06:00
parent 08e4a4a6dd
commit a368f8b322
2 changed files with 6 additions and 4 deletions

View File

@ -155,11 +155,11 @@ class Binance(Exchange):
except ccxt.BaseError as e: except ccxt.BaseError as e:
raise OperationalException(e) from e raise OperationalException(e) from e
def get_max_leverage(self, pair: Optional[str], margin: Optional[float]) -> float: def get_max_leverage(self, pair: str, stake_amount: Optional[float]) -> float:
""" """
Returns the maximum leverage that a pair can be traded at Returns the maximum leverage that a pair can be traded at
:param pair: The base/quote currency pair being traded :param pair: The base/quote currency pair being traded
:margin: The total value of the traders collateral in quote currency :stake_amount: The total value of the traders collateral in quote currency
""" """
if pair not in self._leverage_brackets: if pair not in self._leverage_brackets:
return 1.0 return 1.0
@ -167,9 +167,11 @@ class Binance(Exchange):
max_lev = 1.0 max_lev = 1.0
for [min_amount, margin_req] in pair_brackets: for [min_amount, margin_req] in pair_brackets:
lev = 1/margin_req lev = 1/margin_req
nominal_value = margin * lev nominal_value = stake_amount * lev
if nominal_value >= min_amount: if nominal_value >= min_amount:
max_lev = lev max_lev = lev
else:
break
return max_lev return max_lev
@retrier @retrier

View File

@ -1807,7 +1807,7 @@ class Exchange:
""" """
return return
def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float: def get_max_leverage(self, pair: str, stake_amount: Optional[float]) -> float:
""" """
Returns the maximum leverage that a pair can be traded at Returns the maximum leverage that a pair can be traded at
:param pair: The base/quote currency pair being traded :param pair: The base/quote currency pair being traded