mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
only warn on exceptions in backtest for freqai interface
This commit is contained in:
parent
eddca5a694
commit
c537c43dd0
|
@ -48,6 +48,7 @@
|
||||||
],
|
],
|
||||||
"freqai": {
|
"freqai": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
"warn_exceptions_on_backtest_only": false,
|
||||||
"purge_old_models": 2,
|
"purge_old_models": 2,
|
||||||
"train_period_days": 15,
|
"train_period_days": 15,
|
||||||
"backtest_period_days": 7,
|
"backtest_period_days": 7,
|
||||||
|
|
|
@ -116,6 +116,8 @@ class IFreqaiModel(ABC):
|
||||||
|
|
||||||
record_params(config, self.full_path)
|
record_params(config, self.full_path)
|
||||||
|
|
||||||
|
self.new_feature_selector = self.config.get('freqai', {}).get('warn_exceptions_on_backtest_only', False)
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
"""
|
"""
|
||||||
Return an empty state to be pickled in hyperopt
|
Return an empty state to be pickled in hyperopt
|
||||||
|
@ -354,10 +356,25 @@ class IFreqaiModel(ABC):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Training {pair} raised exception {msg.__class__.__name__}. "
|
f"Training {pair} raised exception {msg.__class__.__name__}. "
|
||||||
f"Message: {msg}, skipping.", exc_info=True)
|
f"Message: {msg}, skipping.", exc_info=True)
|
||||||
|
|
||||||
|
if self.new_feature_selector:
|
||||||
|
logger.warning(
|
||||||
|
"Train failed. Try to train on next pair." if self.new_feature_selector else
|
||||||
|
"Train failed. Raise error, fix data issue and try again."
|
||||||
|
)
|
||||||
|
self.tb_logger.close()
|
||||||
self.model = None
|
self.model = None
|
||||||
|
|
||||||
self.dd.pair_dict[pair]["trained_timestamp"] = int(
|
hard_check_model_valid = True
|
||||||
tr_train.stopts)
|
if self.new_feature_selector:
|
||||||
|
hard_check_model_valid = bool(False if self.model is None else True)
|
||||||
|
if hard_check_model_valid:
|
||||||
|
logger.info(
|
||||||
|
"Model is trained. Saving model and metadata to disk."
|
||||||
|
)
|
||||||
|
|
||||||
|
if hard_check_model_valid:
|
||||||
|
self.dd.pair_dict[pair]["trained_timestamp"] = int(tr_train.stopts)
|
||||||
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:
|
||||||
|
@ -366,9 +383,11 @@ class IFreqaiModel(ABC):
|
||||||
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)
|
||||||
|
|
||||||
|
if hard_check_model_valid:
|
||||||
pred_df, do_preds = self.predict(dataframe_backtest, dk)
|
pred_df, do_preds = self.predict(dataframe_backtest, dk)
|
||||||
append_df = dk.get_predictions_to_append(pred_df, do_preds, dataframe_backtest)
|
append_df = dk.get_predictions_to_append(pred_df, do_preds, dataframe_backtest)
|
||||||
dk.append_predictions(append_df)
|
dk.append_predictions(append_df)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user