X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helper.py;h=8ef2d642203252c8d14ab9328ad1fbcb7e59a4d8;hb=0c79fad318711394874d94672e96db6da1ed9c52;hp=f1aeaf2dbeba2807d29ca632d889761fe647274f;hpb=2308a1c4c0d2514dc9fc9acf235f9e5a33299f63;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git 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