From 0c79fad318711394874d94672e96db6da1ed9c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 12 Feb 2018 02:08:50 +0100 Subject: Fix move_balance not moving currencies absent from trades --- helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'helper.py') diff --git a/helper.py b/helper.py index f1aeaf2..8ef2d64 100644 --- a/helper.py +++ b/helper.py @@ -4,10 +4,13 @@ from store import * def move_balances(market, debug=False): needed_in_margin = {} + for currency in BalanceStore.all: + if BalanceStore.all[currency].margin_free != 0: + needed_in_margin[currency] = 0 for trade in TradeStore.all: + if trade.value_to.currency not in needed_in_margin: + needed_in_margin[trade.value_to.currency] = 0 if trade.trade_type == "short": - if trade.value_to.currency not in needed_in_margin: - needed_in_margin[trade.value_to.currency] = 0 needed_in_margin[trade.value_to.currency] += abs(trade.value_to) for currency, needed in needed_in_margin.items(): current_balance = BalanceStore.all[currency].margin_free -- cgit v1.2.3