get_max_leverage checks if the number of tiers is < 1

This commit is contained in:
Sam Germain 2022-02-10 03:44:22 -06:00
parent 3b43d42eaa
commit 41ab20d949

View File

@ -1931,7 +1931,8 @@ class Exchange:
# Checks and edge cases # Checks and edge cases
if stake_amount is None: if stake_amount is None:
raise OperationalException( raise OperationalException(
'binance.get_max_leverage requires argument stake_amount') f'{self.name}.get_max_leverage requires argument stake_amount'
)
if pair not in self._leverage_tiers: if pair not in self._leverage_tiers:
tiers = self.get_leverage_tiers_for_pair(pair) tiers = self.get_leverage_tiers_for_pair(pair)
@ -1944,6 +1945,9 @@ class Exchange:
pair_tiers = self._leverage_tiers[pair] pair_tiers = self._leverage_tiers[pair]
num_tiers = len(pair_tiers) num_tiers = len(pair_tiers)
if num_tiers < 1:
return 1.0
for tier_index in range(num_tiers): for tier_index in range(num_tiers):
tier = pair_tiers[tier_index] tier = pair_tiers[tier_index]