rewrite fill_leverage_brackets

This commit is contained in:
Sam Germain 2022-01-10 12:28:22 -06:00
parent 69a6223ca0
commit bff53c52af

View File

@ -135,17 +135,19 @@ class Binance(Exchange):
else: else:
leverage_brackets = self._api.load_leverage_brackets() leverage_brackets = self._api.load_leverage_brackets()
for pair, brackets in leverage_brackets.items(): for pair, brkts in leverage_brackets.items():
self._leverage_brackets[pair] = [ [amt, old_ratio] = [None, None]
[ brackets = []
min_amount, for [notional_floor, mm_ratio] in brkts:
float(margin_req) amt = ((float(notional_floor) * (mm_ratio - old_ratio)) +
] for [ amt) if old_ratio else 0
min_amount, old_ratio = mm_ratio
margin_req brackets.append([
] in brackets float(notional_floor),
] mm_ratio,
amt,
])
self._leverage_brackets[pair] = brackets
except ccxt.DDoSProtection as e: except ccxt.DDoSProtection as e:
raise DDosProtection(e) from e raise DDosProtection(e) from e
except (ccxt.NetworkError, ccxt.ExchangeError) as e: except (ccxt.NetworkError, ccxt.ExchangeError) as e: