aboutsummaryrefslogtreecommitdiff
path: root/helper.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-02-12 02:08:50 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-02-12 02:08:50 +0100
commit0c79fad318711394874d94672e96db6da1ed9c52 (patch)
treebf39fa15f5fef160fbb4911f2a67a7aa9236e4cd /helper.py
parent2308a1c4c0d2514dc9fc9acf235f9e5a33299f63 (diff)
downloadTrader-0c79fad318711394874d94672e96db6da1ed9c52.tar.gz
Trader-0c79fad318711394874d94672e96db6da1ed9c52.tar.zst
Trader-0c79fad318711394874d94672e96db6da1ed9c52.zip
Fix move_balance not moving currencies absent from trades
Diffstat (limited to 'helper.py')
-rw-r--r--helper.py7
1 files changed, 5 insertions, 2 deletions
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 *
4 4
5def move_balances(market, debug=False): 5def 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