Introduce self._enabled in pairlist handlers

This commit is contained in:
hroff-1902 2020-05-20 13:41:00 +03:00
parent 7e43574382
commit 4f0d928145
4 changed files with 14 additions and 9 deletions

View File

@ -26,6 +26,8 @@ class IPairList(ABC):
:param pairlistconfig: Configuration for this Pairlist Handler - can be empty. :param pairlistconfig: Configuration for this Pairlist Handler - can be empty.
:param pairlist_pos: Position of the Pairlist Handler in the chain :param pairlist_pos: Position of the Pairlist Handler in the chain
""" """
self._enabled = True
self._exchange = exchange self._exchange = exchange
self._pairlistmanager = pairlistmanager self._pairlistmanager = pairlistmanager
self._config = config self._config = config
@ -103,11 +105,12 @@ class IPairList(ABC):
:param tickers: Tickers (from exchange.get_tickers()). May be cached. :param tickers: Tickers (from exchange.get_tickers()). May be cached.
:return: new whitelist :return: new whitelist
""" """
# Copy list since we're modifying this list if self._enabled:
for p in deepcopy(pairlist): # Copy list since we're modifying this list
# Filter out assets for p in deepcopy(pairlist):
if not self._validate_pair(tickers[p]): # Filter out assets
pairlist.remove(p) if not self._validate_pair(tickers[p]):
pairlist.remove(p)
return pairlist return pairlist

View File

@ -17,8 +17,11 @@ class PrecisionFilter(IPairList):
pairlist_pos: int) -> None: pairlist_pos: int) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) 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 # Precalculate sanitized stoploss value to avoid recalculation for every pair
self._stoploss = 1 - abs(self._config['stoploss']) self._stoploss = 1 - abs(self._stoploss)
@property @property
def needstickers(self) -> bool: def needstickers(self) -> bool:

View File

@ -18,6 +18,7 @@ class PriceFilter(IPairList):
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
self._low_price_ratio = pairlistconfig.get('low_price_ratio', 0) self._low_price_ratio = pairlistconfig.get('low_price_ratio', 0)
self._enabled = self._low_price_ratio != 0
@property @property
def needstickers(self) -> bool: def needstickers(self) -> bool:
@ -40,9 +41,6 @@ class PriceFilter(IPairList):
:param ticker: ticker dict as returned from ccxt.load_markets() :param ticker: ticker dict as returned from ccxt.load_markets()
:return: True if the pair can stay, false if it should be removed :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: if ticker['last'] is None:
self.log_on_refresh(logger.info, self.log_on_refresh(logger.info,
f"Removed {ticker['symbol']} from whitelist, because " f"Removed {ticker['symbol']} from whitelist, because "

View File

@ -18,6 +18,7 @@ class SpreadFilter(IPairList):
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
self._max_spread_ratio = pairlistconfig.get('max_spread_ratio', 0.005) self._max_spread_ratio = pairlistconfig.get('max_spread_ratio', 0.005)
self._enabled = self._max_spread_ratio != 0
@property @property
def needstickers(self) -> bool: def needstickers(self) -> bool: