Updated kraken fill leverage brackets and set_leverage

This commit is contained in:
Sam Germain 2021-09-12 01:51:09 -06:00
parent 1344c9f7fc
commit 09418938fe
2 changed files with 20 additions and 10 deletions

View File

@ -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

View File

@ -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]
}