diff options
Diffstat (limited to 'helper.py')
-rw-r--r-- | helper.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -4,10 +4,13 @@ from store import * | |||
4 | 4 | ||
5 | def move_balances(market, debug=False): | 5 | def move_balances(market, debug=False): |
6 | needed_in_margin = {} | 6 | needed_in_margin = {} |
7 | for currency in BalanceStore.all: | ||
8 | if BalanceStore.all[currency].margin_free != 0: | ||
9 | needed_in_margin[currency] = 0 | ||
7 | for trade in TradeStore.all: | 10 | for trade in TradeStore.all: |
11 | if trade.value_to.currency not in needed_in_margin: | ||
12 | needed_in_margin[trade.value_to.currency] = 0 | ||
8 | if trade.trade_type == "short": | 13 | if trade.trade_type == "short": |
9 | if trade.value_to.currency not in needed_in_margin: | ||
10 | needed_in_margin[trade.value_to.currency] = 0 | ||
11 | needed_in_margin[trade.value_to.currency] += abs(trade.value_to) | 14 | needed_in_margin[trade.value_to.currency] += abs(trade.value_to) |
12 | for currency, needed in needed_in_margin.items(): | 15 | for currency, needed in needed_in_margin.items(): |
13 | current_balance = BalanceStore.all[currency].margin_free | 16 | current_balance = BalanceStore.all[currency].margin_free |