ruff reformatted

This commit is contained in:
Aleksey Savin 2024-06-01 17:16:10 +03:00
parent 7a04f876c3
commit d7b86ee436

View File

@ -261,7 +261,8 @@ class IFreqaiModel(ABC):
def _train_model(self, dataframe_train, pair, dk, tr_backtest): def _train_model(self, dataframe_train, pair, dk, tr_backtest):
try: try:
self.tb_logger = get_tb_logger( self.tb_logger = get_tb_logger(
self.dd.model_type, dk.data_path, self.activate_tensorboard) self.dd.model_type, dk.data_path, self.activate_tensorboard
)
model = self.train(dataframe_train, pair, dk) model = self.train(dataframe_train, pair, dk)
self.tb_logger.close() self.tb_logger.close()
return model return model
@ -269,7 +270,9 @@ class IFreqaiModel(ABC):
logger.warning( logger.warning(
f"Training {pair} raised exception {msg.__class__.__name__}. " f"Training {pair} raised exception {msg.__class__.__name__}. "
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}." f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}."
f"Message: {msg}, skipping.", exc_info=True) f"Message: {msg}, skipping.",
exc_info=True,
)
return None return None
def start_backtesting( def start_backtesting(
@ -373,10 +376,10 @@ class IFreqaiModel(ABC):
if self.plot_features and self.model is not None: if self.plot_features and self.model is not None:
plot_feature_importance(self.model, pair, dk, self.plot_features) plot_feature_importance(self.model, pair, dk, self.plot_features)
if self.save_backtest_models and self.model is not None: if self.save_backtest_models and self.model is not None:
logger.info('Saving backtest model to disk.') logger.info("Saving backtest model to disk.")
self.dd.save_data(self.model, pair, dk) self.dd.save_data(self.model, pair, dk)
else: else:
logger.info('Saving metadata to disk.') logger.info("Saving metadata to disk.")
self.dd.save_metadata(dk) self.dd.save_metadata(dk)
else: else:
self.model = self.dd.load_data(pair, dk) self.model = self.dd.load_data(pair, dk)
@ -833,9 +836,11 @@ class IFreqaiModel(ABC):
:return: if the data exists or not :return: if the data exists or not
""" """
if len_dataframe_backtest == 0: if len_dataframe_backtest == 0:
logger.info(f"No data found for pair {pair} from " logger.info(
f"No data found for pair {pair} from "
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}. " f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}. "
"Probably more than one training within the same candle period.") "Probably more than one training within the same candle period."
)
return False return False
return True return True