mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Merge d7b86ee436
into ae41ab101a
This commit is contained in:
commit
3a806ef2d9
|
@ -70,7 +70,7 @@ class IFreqaiModel(ABC):
|
|||
self.retrain = False
|
||||
self.first = True
|
||||
self.set_full_path()
|
||||
self.save_backtest_models: bool = self.freqai_info.get("save_backtest_models", True)
|
||||
self.save_backtest_models: bool = self.freqai_info.get("save_backtest_models", False)
|
||||
if self.save_backtest_models:
|
||||
logger.info("Backtesting module configured to save all models.")
|
||||
|
||||
|
@ -258,6 +258,23 @@ class IFreqaiModel(ABC):
|
|||
if self.freqai_info.get("write_metrics_to_disk", False):
|
||||
self.dd.save_metric_tracker_to_disk()
|
||||
|
||||
def _train_model(self, dataframe_train, pair, dk, tr_backtest):
|
||||
try:
|
||||
self.tb_logger = get_tb_logger(
|
||||
self.dd.model_type, dk.data_path, self.activate_tensorboard
|
||||
)
|
||||
model = self.train(dataframe_train, pair, dk)
|
||||
self.tb_logger.close()
|
||||
return model
|
||||
except Exception as msg:
|
||||
logger.warning(
|
||||
f"Training {pair} raised exception {msg.__class__.__name__}. "
|
||||
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}."
|
||||
f"Message: {msg}, skipping.",
|
||||
exc_info=True,
|
||||
)
|
||||
return None
|
||||
|
||||
def start_backtesting(
|
||||
self, dataframe: DataFrame, metadata: dict, dk: FreqaiDataKitchen, strategy: IStrategy
|
||||
) -> FreqaiDataKitchen:
|
||||
|
@ -352,21 +369,9 @@ class IFreqaiModel(ABC):
|
|||
if not self.model_exists(dk):
|
||||
dk.find_features(dataframe_train)
|
||||
dk.find_labels(dataframe_train)
|
||||
self.model = self._train_model(dataframe_train, pair, dk, tr_backtest)
|
||||
|
||||
try:
|
||||
self.tb_logger = get_tb_logger(
|
||||
self.dd.model_type, dk.data_path, self.activate_tensorboard
|
||||
)
|
||||
self.model = self.train(dataframe_train, pair, dk)
|
||||
self.tb_logger.close()
|
||||
except Exception as msg:
|
||||
logger.warning(
|
||||
f"Training {pair} raised exception {msg.__class__.__name__}. "
|
||||
f"Message: {msg}, skipping.",
|
||||
exc_info=True,
|
||||
)
|
||||
self.model = None
|
||||
|
||||
if self.model:
|
||||
self.dd.pair_dict[pair]["trained_timestamp"] = int(tr_train.stopts)
|
||||
if self.plot_features and self.model is not None:
|
||||
plot_feature_importance(self.model, pair, dk, self.plot_features)
|
||||
|
@ -379,6 +384,7 @@ class IFreqaiModel(ABC):
|
|||
else:
|
||||
self.model = self.dd.load_data(pair, dk)
|
||||
|
||||
if self.model and len(dataframe_backtest):
|
||||
pred_df, do_preds = self.predict(dataframe_backtest, dk)
|
||||
append_df = dk.get_predictions_to_append(pred_df, do_preds, dataframe_backtest)
|
||||
dk.append_predictions(append_df)
|
||||
|
@ -829,7 +835,7 @@ class IFreqaiModel(ABC):
|
|||
:param pair: current pair
|
||||
:return: if the data exists or not
|
||||
"""
|
||||
if self.config.get("freqai_backtest_live_models", False) and len_dataframe_backtest == 0:
|
||||
if len_dataframe_backtest == 0:
|
||||
logger.info(
|
||||
f"No data found for pair {pair} from "
|
||||
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}. "
|
||||
|
|
Loading…
Reference in New Issue
Block a user