]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - store.py
Add tags to balance log
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / store.py
index dfadef22e1d2ad5e7591d5793bbaefbfc8105857..a7aad22d9fcab3933307df21f7974497ba996f61 100644 (file)
--- a/store.py
+++ b/store.py
@@ -43,13 +43,14 @@ class ReportStore:
             })
 
     @classmethod
-    def log_balances(cls, market):
+    def log_balances(cls, market, tag=None):
         cls.print_log("[Balance]")
         for currency, balance in BalanceStore.all.items():
             cls.print_log("\t{}".format(balance))
 
         cls.add_log({
             "type": "balance",
+            "tag": tag,
             "balances": BalanceStore.as_json()
             })
 
@@ -196,13 +197,13 @@ class BalanceStore:
         return amounts
 
     @classmethod
-    def fetch_balances(cls, market):
+    def fetch_balances(cls, market, tag=None):
         all_balances = market.fetch_all_balances()
         for currency, balance in all_balances.items():
             if balance["exchange_total"] != 0 or balance["margin_total"] != 0 or \
                     currency in cls.all:
                 cls.all[currency] = portfolio.Balance(currency, balance)
-        ReportStore.log_balances(market)
+        ReportStore.log_balances(market, tag=tag)
 
     @classmethod
     def dispatch_assets(cls, amount, liquidity="medium", repartition=None):