diff options
Diffstat (limited to 'store.py')
-rw-r--r-- | store.py | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -304,7 +304,7 @@ class BalanceStore: | |||
304 | compute_value, type) | 304 | compute_value, type) |
305 | return amounts | 305 | return amounts |
306 | 306 | ||
307 | def fetch_balances(self, tag=None, add_portfolio=False, | 307 | def fetch_balances(self, tag=None, add_portfolio=False, liquidity="medium", |
308 | checkpoint=None, log_tickers=False, add_usdt=False, | 308 | checkpoint=None, log_tickers=False, add_usdt=False, |
309 | ticker_currency="BTC", ticker_compute_value="average", ticker_type="total"): | 309 | ticker_currency="BTC", ticker_compute_value="average", ticker_type="total"): |
310 | all_balances = self.market.ccxt.fetch_all_balances() | 310 | all_balances = self.market.ccxt.fetch_all_balances() |
@@ -313,7 +313,7 @@ class BalanceStore: | |||
313 | currency in self.all: | 313 | currency in self.all: |
314 | self.all[currency] = portfolio.Balance(currency, balance) | 314 | self.all[currency] = portfolio.Balance(currency, balance) |
315 | if add_portfolio: | 315 | if add_portfolio: |
316 | for currency in Portfolio.repartition(from_cache=True): | 316 | for currency in Portfolio.repartition(from_cache=True, liquidity=liquidity): |
317 | self.all.setdefault(currency, portfolio.Balance(currency, {})) | 317 | self.all.setdefault(currency, portfolio.Balance(currency, {})) |
318 | if add_usdt: | 318 | if add_usdt: |
319 | self.all.setdefault("USDT", portfolio.Balance("USDT", {})) | 319 | self.all.setdefault("USDT", portfolio.Balance("USDT", {})) |
@@ -517,7 +517,7 @@ class Portfolio: | |||
517 | elif delta < datetime.timedelta(days=1): | 517 | elif delta < datetime.timedelta(days=1): |
518 | return 60*60 | 518 | return 60*60 |
519 | else: | 519 | else: |
520 | raise "Too long waiting" | 520 | raise Exception("Too long waiting") |
521 | 521 | ||
522 | @classmethod | 522 | @classmethod |
523 | def start_worker(cls): | 523 | def start_worker(cls): |
@@ -555,7 +555,10 @@ class Portfolio: | |||
555 | cls.report.print_log("[Worker] Fetching cryptoportfolio") | 555 | cls.report.print_log("[Worker] Fetching cryptoportfolio") |
556 | cls.get_cryptoportfolio(refetch=True) | 556 | cls.get_cryptoportfolio(refetch=True) |
557 | cls.callback.set() | 557 | cls.callback.set() |
558 | time.sleep(cls.next_wait_time()) | 558 | try: |
559 | time.sleep(cls.next_wait_time()) | ||
560 | except Exception: | ||
561 | cls.stop_worker() | ||
559 | 562 | ||
560 | @classmethod | 563 | @classmethod |
561 | def stop_worker(cls): | 564 | def stop_worker(cls): |
@@ -591,6 +594,8 @@ class Portfolio: | |||
591 | if cls.data.get() is not None and not refetch: | 594 | if cls.data.get() is not None and not refetch: |
592 | return | 595 | return |
593 | if cls.worker is not None and not cls.is_worker_thread(): | 596 | if cls.worker is not None and not cls.is_worker_thread(): |
597 | if not cls.worker_started: | ||
598 | raise Exception("Portfolio worker is down and no usable data is present") | ||
594 | cls.notify_and_wait() | 599 | cls.notify_and_wait() |
595 | return | 600 | return |
596 | try: | 601 | try: |