Show only whitelist warnings
This commit is contained in:
@@ -9,8 +9,8 @@ class LoggingMixin:
|
|||||||
Shows similar messages only once every `refresh_period`.
|
Shows similar messages only once every `refresh_period`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Disable INFO output when False
|
# Disable output completely
|
||||||
show_info_output = True
|
show_output = True
|
||||||
|
|
||||||
def __init__(self, logger, refresh_period: int = 3600):
|
def __init__(self, logger, refresh_period: int = 3600):
|
||||||
"""
|
"""
|
||||||
@@ -35,10 +35,6 @@ class LoggingMixin:
|
|||||||
|
|
||||||
# Log as debug first
|
# Log as debug first
|
||||||
self.logger.debug(message)
|
self.logger.debug(message)
|
||||||
|
# Call hidden function.
|
||||||
# Determine if this is an INFO level message
|
if self.show_output:
|
||||||
is_info_message = getattr(logmethod, "__name__", "") == "info"
|
|
||||||
|
|
||||||
# For INFO messages, respect show_info_output flag
|
|
||||||
if not is_info_message or self.show_info_output:
|
|
||||||
_log_once(message)
|
_log_once(message)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class Backtesting:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, config: Config, exchange: Exchange | None = None) -> None:
|
def __init__(self, config: Config, exchange: Exchange | None = None) -> None:
|
||||||
LoggingMixin.show_info_output = False
|
LoggingMixin.show_output = False
|
||||||
self.config = config
|
self.config = config
|
||||||
self.results: BacktestResultType = get_BacktestResultType_default()
|
self.results: BacktestResultType = get_BacktestResultType_default()
|
||||||
self.trade_id_counter: int = 0
|
self.trade_id_counter: int = 0
|
||||||
@@ -235,7 +235,7 @@ class Backtesting:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cleanup():
|
def cleanup():
|
||||||
LoggingMixin.show_info_output = True
|
LoggingMixin.show_output = True
|
||||||
enable_database_use()
|
enable_database_use()
|
||||||
|
|
||||||
def init_backtest_detail(self) -> None:
|
def init_backtest_detail(self) -> None:
|
||||||
|
|||||||
@@ -237,6 +237,11 @@ class IPairList(LoggingMixin, ABC):
|
|||||||
:return: the list of pairs the user wants to trade without those unavailable or
|
:return: the list of pairs the user wants to trade without those unavailable or
|
||||||
black_listed
|
black_listed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Save show_output value and set it to True
|
||||||
|
prev_show_output = self.show_output
|
||||||
|
self.show_output = True
|
||||||
|
|
||||||
markets = self._exchange.markets
|
markets = self._exchange.markets
|
||||||
if not markets:
|
if not markets:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
@@ -277,5 +282,8 @@ class IPairList(LoggingMixin, ABC):
|
|||||||
if pair not in sanitized_whitelist:
|
if pair not in sanitized_whitelist:
|
||||||
sanitized_whitelist.append(pair)
|
sanitized_whitelist.append(pair)
|
||||||
|
|
||||||
|
# Return show_output to its previous value
|
||||||
|
self.show_output = prev_show_output
|
||||||
|
|
||||||
# We need to remove pairs that are unknown
|
# We need to remove pairs that are unknown
|
||||||
return sanitized_whitelist
|
return sanitized_whitelist
|
||||||
|
|||||||
Reference in New Issue
Block a user