From 696c7e87f24dad77df7820cdaa1e88a3768e468f Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Tue, 19 May 2020 23:51:39 +0300 Subject: [PATCH] Use proper logging (using the Filter's logger) --- freqtrade/pairlist/IPairList.py | 6 +++--- freqtrade/pairlist/VolumePairList.py | 2 +- freqtrade/pairlist/pairlistmanager.py | 14 ++++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/freqtrade/pairlist/IPairList.py b/freqtrade/pairlist/IPairList.py index 4afbe1c72..bd8e843e6 100644 --- a/freqtrade/pairlist/IPairList.py +++ b/freqtrade/pairlist/IPairList.py @@ -86,14 +86,14 @@ class IPairList(ABC): :return: new whitelist """ - def verify_blacklist(self, pairlist: List[str]) -> List[str]: + def verify_blacklist(self, pairlist: List[str], logmethod) -> List[str]: """ Proxy method to verify_blacklist for easy access for child classes. - Uses `aswarning=False`, as it should be for Pairlist Handlers. :param pairlist: Pairlist to validate + :param logmethod: Function that'll be called, `logger.info` or `logger.warning`. :return: pairlist - blacklisted pairs """ - return self._pairlistmanager.verify_blacklist(pairlist, aswarning=False) + return self._pairlistmanager.verify_blacklist(pairlist, logmethod) def _whitelist_for_active_markets(self, pairlist: List[str]) -> List[str]: """ diff --git a/freqtrade/pairlist/VolumePairList.py b/freqtrade/pairlist/VolumePairList.py index b254921cf..b792ab037 100644 --- a/freqtrade/pairlist/VolumePairList.py +++ b/freqtrade/pairlist/VolumePairList.py @@ -115,7 +115,7 @@ class VolumePairList(IPairList): # Validate whitelist to only have active market pairs pairs = self._whitelist_for_active_markets([s['symbol'] for s in sorted_tickers]) - pairs = self.verify_blacklist(pairs) + pairs = self.verify_blacklist(pairs, logger.info) # Limit pairlist to the requested number of pairs pairs = pairs[:self._number_pairs] diff --git a/freqtrade/pairlist/pairlistmanager.py b/freqtrade/pairlist/pairlistmanager.py index a953a586f..6ad6c610b 100644 --- a/freqtrade/pairlist/pairlistmanager.py +++ b/freqtrade/pairlist/pairlistmanager.py @@ -93,7 +93,7 @@ class PairListManager(): # Validation against blacklist happens after the chain of Pairlist Handlers # to ensure blacklist is respected. - pairlist = self.verify_blacklist(pairlist, True) + pairlist = self.verify_blacklist(pairlist, logger.warning) self._whitelist = pairlist @@ -110,21 +110,19 @@ class PairListManager(): return pairlist - def verify_blacklist(self, pairlist: List[str], aswarning: bool) -> List[str]: + def verify_blacklist(self, pairlist: List[str], logmethod) -> List[str]: """ Verify and remove items from pairlist - returning a filtered pairlist. Logs a warning or info depending on `aswarning`. - Pairlist Handlers explicitly using this method shall use `aswarning=False`! + Pairlist Handlers explicitly using this method shall use + `logmethod=logger.info` to avoid spamming with warning messages :param pairlist: Pairlist to validate - :param aswarning: Log message as Warning or Info + :param logmethod: Function that'll be called, `logger.info` or `logger.warning`. :return: pairlist - blacklisted pairs """ for pair in deepcopy(pairlist): if pair in self._blacklist: - if aswarning: - logger.warning(f"Pair {pair} in your blacklist. Removing it from whitelist...") - else: - logger.info(f"Pair {pair} in your blacklist. Removing it from whitelist...") + logmethod(f"Pair {pair} in your blacklist. Removing it from whitelist...") pairlist.remove(pair) return pairlist