From 4f0d928145faff6ac36e0f9541d2777012348459 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Wed, 20 May 2020 13:41:00 +0300 Subject: [PATCH] Introduce self._enabled in pairlist handlers --- freqtrade/pairlist/IPairList.py | 13 ++++++++----- freqtrade/pairlist/PrecisionFilter.py | 5 ++++- freqtrade/pairlist/PriceFilter.py | 4 +--- freqtrade/pairlist/SpreadFilter.py | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/freqtrade/pairlist/IPairList.py b/freqtrade/pairlist/IPairList.py index b93621f2e..e49ad1561 100644 --- a/freqtrade/pairlist/IPairList.py +++ b/freqtrade/pairlist/IPairList.py @@ -26,6 +26,8 @@ class IPairList(ABC): :param pairlistconfig: Configuration for this Pairlist Handler - can be empty. :param pairlist_pos: Position of the Pairlist Handler in the chain """ + self._enabled = True + self._exchange = exchange self._pairlistmanager = pairlistmanager self._config = config @@ -103,11 +105,12 @@ class IPairList(ABC): :param tickers: Tickers (from exchange.get_tickers()). May be cached. :return: new whitelist """ - # Copy list since we're modifying this list - for p in deepcopy(pairlist): - # Filter out assets - if not self._validate_pair(tickers[p]): - pairlist.remove(p) + if self._enabled: + # Copy list since we're modifying this list + for p in deepcopy(pairlist): + # Filter out assets + if not self._validate_pair(tickers[p]): + pairlist.remove(p) return pairlist diff --git a/freqtrade/pairlist/PrecisionFilter.py b/freqtrade/pairlist/PrecisionFilter.py index 4abc9b637..0331347be 100644 --- a/freqtrade/pairlist/PrecisionFilter.py +++ b/freqtrade/pairlist/PrecisionFilter.py @@ -17,8 +17,11 @@ class PrecisionFilter(IPairList): pairlist_pos: int) -> None: super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) + self._stoploss = self._config['stoploss'] + self._enabled = self._stoploss != 0 + # Precalculate sanitized stoploss value to avoid recalculation for every pair - self._stoploss = 1 - abs(self._config['stoploss']) + self._stoploss = 1 - abs(self._stoploss) @property def needstickers(self) -> bool: diff --git a/freqtrade/pairlist/PriceFilter.py b/freqtrade/pairlist/PriceFilter.py index ade524fe7..b85d68269 100644 --- a/freqtrade/pairlist/PriceFilter.py +++ b/freqtrade/pairlist/PriceFilter.py @@ -18,6 +18,7 @@ class PriceFilter(IPairList): super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) self._low_price_ratio = pairlistconfig.get('low_price_ratio', 0) + self._enabled = self._low_price_ratio != 0 @property def needstickers(self) -> bool: @@ -40,9 +41,6 @@ class PriceFilter(IPairList): :param ticker: ticker dict as returned from ccxt.load_markets() :return: True if the pair can stay, false if it should be removed """ - if not self._low_price_ratio: - return True - if ticker['last'] is None: self.log_on_refresh(logger.info, f"Removed {ticker['symbol']} from whitelist, because " diff --git a/freqtrade/pairlist/SpreadFilter.py b/freqtrade/pairlist/SpreadFilter.py index 4d6a2bad9..0147c0068 100644 --- a/freqtrade/pairlist/SpreadFilter.py +++ b/freqtrade/pairlist/SpreadFilter.py @@ -18,6 +18,7 @@ class SpreadFilter(IPairList): super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) self._max_spread_ratio = pairlistconfig.get('max_spread_ratio', 0.005) + self._enabled = self._max_spread_ratio != 0 @property def needstickers(self) -> bool: