]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - store.py
Add checkpoints when fetching balance
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / store.py
index 76cfec88f4648e55cd9f1b084204e46f5ad730b4..2a71bed1e55c0cd9c7e1e417f05d6c7cd24d2350 100644 (file)
--- a/store.py
+++ b/store.py
@@ -99,7 +99,7 @@ class ReportStore:
             "args": args,
             })
 
-    def log_balances(self, tag=None, tickers=None,
+    def log_balances(self, tag=None, checkpoint=None, tickers=None,
             ticker_currency=None, compute_value=None, type=None):
         self.print_log("[Balance]")
         for currency, balance in self.market.balances.all.items():
@@ -108,6 +108,7 @@ class ReportStore:
         log = {
                 "type": "balance",
                 "tag": tag,
+                "checkpoint": checkpoint,
                 "balances": self.market.balances.as_json()
                 }
 
@@ -303,7 +304,8 @@ class BalanceStore:
                 compute_value, type)
         return amounts
 
-    def fetch_balances(self, tag=None, add_portfolio=False, log_tickers=False,
+    def fetch_balances(self, tag=None, add_portfolio=False,
+            checkpoint=None, log_tickers=False,
             ticker_currency="BTC", ticker_compute_value="average", ticker_type="total"):
         all_balances = self.market.ccxt.fetch_all_balances()
         for currency, balance in all_balances.items():
@@ -315,11 +317,11 @@ class BalanceStore:
                 self.all.setdefault(currency, portfolio.Balance(currency, {}))
         if log_tickers:
             tickers = self.in_currency(ticker_currency, compute_value=ticker_compute_value, type=ticker_type)
-            self.market.report.log_balances(tag=tag,
+            self.market.report.log_balances(tag=tag, checkpoint=checkpoint,
                     tickers=tickers, ticker_currency=ticker_currency,
                     compute_value=ticker_compute_value, type=ticker_type)
         else:
-            self.market.report.log_balances(tag=tag)
+            self.market.report.log_balances(tag=tag, checkpoint=checkpoint)
 
     def dispatch_assets(self, amount, liquidity="medium", repartition=None):
         if repartition is None: