aboutsummaryrefslogtreecommitdiff
path: root/store.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-02-24 22:12:29 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-02-24 22:12:29 +0100
commit18167a3c502e9d61828067c3f6e56b5182584249 (patch)
tree9c0fedd7e1e66bf25dfec9515c576d5b9dcdd3f3 /store.py
parent3d0247f944d7510943dfaa64eeb0e15a43b6c989 (diff)
downloadTrader-18167a3c502e9d61828067c3f6e56b5182584249.tar.gz
Trader-18167a3c502e9d61828067c3f6e56b5182584249.tar.zst
Trader-18167a3c502e9d61828067c3f6e56b5182584249.zip
Add tags to balance log
Diffstat (limited to 'store.py')
-rw-r--r--store.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/store.py b/store.py
index dfadef2..a7aad22 100644
--- a/store.py
+++ b/store.py
@@ -43,13 +43,14 @@ class ReportStore:
43 }) 43 })
44 44
45 @classmethod 45 @classmethod
46 def log_balances(cls, market): 46 def log_balances(cls, market, tag=None):
47 cls.print_log("[Balance]") 47 cls.print_log("[Balance]")
48 for currency, balance in BalanceStore.all.items(): 48 for currency, balance in BalanceStore.all.items():
49 cls.print_log("\t{}".format(balance)) 49 cls.print_log("\t{}".format(balance))
50 50
51 cls.add_log({ 51 cls.add_log({
52 "type": "balance", 52 "type": "balance",
53 "tag": tag,
53 "balances": BalanceStore.as_json() 54 "balances": BalanceStore.as_json()
54 }) 55 })
55 56
@@ -196,13 +197,13 @@ class BalanceStore:
196 return amounts 197 return amounts
197 198
198 @classmethod 199 @classmethod
199 def fetch_balances(cls, market): 200 def fetch_balances(cls, market, tag=None):
200 all_balances = market.fetch_all_balances() 201 all_balances = market.fetch_all_balances()
201 for currency, balance in all_balances.items(): 202 for currency, balance in all_balances.items():
202 if balance["exchange_total"] != 0 or balance["margin_total"] != 0 or \ 203 if balance["exchange_total"] != 0 or balance["margin_total"] != 0 or \
203 currency in cls.all: 204 currency in cls.all:
204 cls.all[currency] = portfolio.Balance(currency, balance) 205 cls.all[currency] = portfolio.Balance(currency, balance)
205 ReportStore.log_balances(market) 206 ReportStore.log_balances(market, tag=tag)
206 207
207 @classmethod 208 @classmethod
208 def dispatch_assets(cls, amount, liquidity="medium", repartition=None): 209 def dispatch_assets(cls, amount, liquidity="medium", repartition=None):