X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=store.py;h=32c41211050c83d97c554e84ae29d188c457f3e0;hb=3a15ffc79ea84e5ec6200545bcbf11fc6c1c6564;hp=76cfec88f4648e55cd9f1b084204e46f5ad730b4;hpb=56c3a6078a2740d43072dfe30f07b17b442e3cc2;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/store.py b/store.py index 76cfec8..32c4121 100644 --- 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, add_usdt=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(): @@ -313,13 +315,15 @@ class BalanceStore: if add_portfolio: for currency in Portfolio.repartition(from_cache=True): self.all.setdefault(currency, portfolio.Balance(currency, {})) + if add_usdt: + self.all.setdefault("USDT", portfolio.Balance("USDT", {})) 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: