Fix Kraken balance update error

closes #4873
This commit is contained in:
Matthias 2021-05-05 06:47:26 +02:00
parent 4d9dc2a2ff
commit da47f4e1a4
2 changed files with 4 additions and 1 deletions

View File

@ -53,6 +53,8 @@ class Kraken(Exchange):
# x["side"], x["amount"], # x["side"], x["amount"],
) for x in orders] ) for x in orders]
for bal in balances: for bal in balances:
if not isinstance(balances[bal], dict):
continue
balances[bal]['used'] = sum(order[1] for order in order_list if order[0] == bal) balances[bal]['used'] = sum(order[1] for order in order_list if order[0] == bal)
balances[bal]['free'] = balances[bal]['total'] - balances[bal]['used'] balances[bal]['free'] = balances[bal]['total'] - balances[bal]['used']

View File

@ -90,6 +90,7 @@ def test_get_balances_prod(default_conf, mocker):
'3ST': balance_item.copy(), '3ST': balance_item.copy(),
'4ST': balance_item.copy(), '4ST': balance_item.copy(),
'EUR': balance_item.copy(), 'EUR': balance_item.copy(),
'timestamp': 123123
}) })
kraken_open_orders = [{'symbol': '1ST/EUR', kraken_open_orders = [{'symbol': '1ST/EUR',
'type': 'limit', 'type': 'limit',
@ -138,7 +139,7 @@ def test_get_balances_prod(default_conf, mocker):
default_conf['dry_run'] = False default_conf['dry_run'] = False
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="kraken") exchange = get_patched_exchange(mocker, default_conf, api_mock, id="kraken")
balances = exchange.get_balances() balances = exchange.get_balances()
assert len(balances) == 5 assert len(balances) == 6
assert balances['1ST']['free'] == 9.0 assert balances['1ST']['free'] == 9.0
assert balances['1ST']['total'] == 10.0 assert balances['1ST']['total'] == 10.0