From 09418938fe920ae9f9dc335d54705f2347f102f9 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sun, 12 Sep 2021 01:51:09 -0600 Subject: [PATCH] Updated kraken fill leverage brackets and set_leverage --- freqtrade/exchange/kraken.py | 15 ++++++++------- tests/exchange/test_kraken.py | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index b72a92070..97125f7ec 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -146,6 +146,7 @@ class Kraken(Exchange): leverages = {} for pair, market in self.markets.items(): + leverages[pair] = [1] info = market['info'] leverage_buy = info.get('leverage_buy', []) leverage_sell = info.get('leverage_sell', []) @@ -155,12 +156,12 @@ class Kraken(Exchange): f"The buy({leverage_buy}) and sell({leverage_sell}) leverage are not equal" "for {pair}. Please notify freqtrade because this has never happened before" ) - if max(leverage_buy) < max(leverage_sell): - leverages[pair] = leverage_buy + if max(leverage_buy) <= max(leverage_sell): + leverages[pair] += [int(lev) for lev in leverage_buy] else: - leverages[pair] = leverage_sell + leverages[pair] += [int(lev) for lev in leverage_sell] else: - leverages[pair] = leverage_buy + leverages[pair] += [int(lev) for lev in leverage_buy] self._leverage_brackets = leverages def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float: @@ -173,7 +174,7 @@ class Kraken(Exchange): def set_leverage(self, pair, leverage): """ - Kraken set's the leverage as an option in the order object, so it doesn't do - anything in this function + Kraken set's the leverage as an option in the order object, so we need to + add it to params """ - return + self._params['leverage'] = leverage diff --git a/tests/exchange/test_kraken.py b/tests/exchange/test_kraken.py index 66e7f4f0b..74a06c96c 100644 --- a/tests/exchange/test_kraken.py +++ b/tests/exchange/test_kraken.py @@ -292,7 +292,16 @@ def test_fill_leverage_brackets_kraken(default_conf, mocker): exchange.fill_leverage_brackets() assert exchange._leverage_brackets == { - 'BLK/BTC': ['2', '3'], - 'TKN/BTC': ['2', '3', '4', '5'], - 'ETH/BTC': ['2'] + 'BLK/BTC': [1, 2, 3], + 'TKN/BTC': [1, 2, 3, 4, 5], + 'ETH/BTC': [1, 2], + 'LTC/BTC': [1], + 'XRP/BTC': [1], + 'NEO/BTC': [1], + 'BTT/BTC': [1], + 'ETH/USDT': [1], + 'LTC/USDT': [1], + 'LTC/USD': [1], + 'XLTCUSDT': [1], + 'LTC/ETH': [1] }