Merge pull request #11628 from mrpabloyeah/allow-warning-messages-when-starting-backtesting

Allow warning messages when starting backtesting
This commit is contained in:
Matthias
2025-04-13 19:28:20 +02:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

@@ -20,12 +20,13 @@ class LoggingMixin:
self.refresh_period = refresh_period
self._log_cache: TTLCache = TTLCache(maxsize=1024, ttl=self.refresh_period)
def log_once(self, message: str, logmethod: Callable) -> None:
def log_once(self, message: str, logmethod: Callable, force_show: bool = False) -> None:
"""
Logs message - not more often than "refresh_period" to avoid log spamming
Logs the log-message as debug as well to simplify debugging.
:param message: String containing the message to be sent to the function.
:param logmethod: Function that'll be called. Most likely `logger.info`.
:param force_show: If True, sends the message regardless of show_output value.
:return: None.
"""
@@ -35,6 +36,7 @@ class LoggingMixin:
# Log as debug first
self.logger.debug(message)
# Call hidden function.
if self.show_output:
# Call hidden function if show_output is True or force_show is True
if self.show_output or force_show:
_log_once(message)

View File

@@ -251,6 +251,7 @@ class IPairList(LoggingMixin, ABC):
f"Pair {pair} is not compatible with exchange "
f"{self._exchange.name}. Removing it from whitelist..",
logger.warning,
True,
)
continue
@@ -258,6 +259,7 @@ class IPairList(LoggingMixin, ABC):
self.log_once(
f"Pair {pair} is not tradable with Freqtrade. Removing it from whitelist..",
logger.warning,
True,
)
continue
@@ -266,13 +268,18 @@ class IPairList(LoggingMixin, ABC):
f"Pair {pair} is not compatible with your stake currency "
f"{self._config['stake_currency']}. Removing it from whitelist..",
logger.warning,
True,
)
continue
# Check if market is active
market = markets[pair]
if not market_is_active(market):
self.log_once(f"Ignoring {pair} from whitelist. Market is not active.", logger.info)
self.log_once(
f"Ignoring {pair} from whitelist. Market is not active.",
logger.info,
True,
)
continue
if pair not in sanitized_whitelist:
sanitized_whitelist.append(pair)