Compare commits

...

20 Commits

Author SHA1 Message Date
Alxy Savin
12ef588bd6
Merge d7b86ee436 into c28446dad0 2024-09-18 04:52:20 +02:00
Matthias
c28446dad0
Merge pull request #10672 from freqtrade/update/pre-commit-hooks
Some checks are pending
Build Documentation / Deploy Docs through mike (push) Waiting to run
Update pre-commit hooks
2024-09-17 06:28:16 +02:00
xmatthias
ff9d1f2728 chore: update pre-commit hooks 2024-09-17 03:03:39 +00:00
Aleksey Savin
d7b86ee436 ruff reformatted 2024-06-01 17:16:10 +03:00
Aleksey Savin
7a04f876c3 Merge branch 'develop' into Error-Skipping 2024-06-01 17:01:47 +03:00
Aleksey Savin
0ef7e9db13
Merge branch 'develop' into Error-Skipping 2024-06-01 00:33:53 +03:00
Aleksey Savin
ac5c22d0bc ... 2024-06-01 00:32:05 +03:00
Aleksey Savin
98ef62cb46
Delete makefile 2024-06-01 00:26:05 +03:00
Aleksey Savin
45c8161448 for local testing 2024-05-31 21:07:43 +00:00
Aleksey Savin
62c64e2467 I tweaked the ensure_data_exists function so that it always works without parameter 2024-04-28 19:59:47 +00:00
Matthias
fce4536ef2 Merge branch 'develop' into Error-Skipping 2024-04-25 21:12:20 +02:00
Aleksey Savin
0008a87232 Merge remote-tracking branch 'upstream/develop' into Error-Skipping 2024-04-25 18:38:58 +03:00
Aleksey Savin
116bcc2bce check for backtesting dataframe 2024-04-25 14:35:02 +00:00
Aleksey Savin
778add6d92 default save_backtest_models sync with docs 2024-04-25 08:18:52 +00:00
Aleksey Savin
5782124df9 flake8 2024-04-23 23:18:32 +00:00
Aleksey Savin
c5e68afb2c remove union 2024-04-23 23:11:08 +00:00
Aleksey Savin
49487afc86 fix for merge 2024-04-23 22:42:04 +00:00
Aleksey Savin
4b9f0c2fc2 remove new feature flag 2024-04-23 18:48:01 +00:00
Aleksey Savin
a72587576e check and fix formating code with ruff 2024-04-18 09:27:30 +00:00
Aleksey Savin
c537c43dd0 only warn on exceptions in backtest for freqai interface 2024-04-18 09:09:01 +00:00
2 changed files with 36 additions and 30 deletions

View File

@ -31,7 +31,7 @@ repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.6.4'
rev: 'v0.6.5'
hooks:
- id: ruff
- id: ruff-format

View File

@ -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,37 +369,26 @@ 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
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)
if self.save_backtest_models and self.model is not None:
logger.info("Saving backtest model to disk.")
self.dd.save_data(self.model, pair, dk)
else:
logger.info("Saving metadata to disk.")
self.dd.save_metadata(dk)
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)
if self.save_backtest_models and self.model is not None:
logger.info("Saving backtest model to disk.")
self.dd.save_data(self.model, pair, dk)
else:
logger.info("Saving metadata to disk.")
self.dd.save_metadata(dk)
else:
self.model = self.dd.load_data(pair, dk)
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)
dk.save_backtesting_prediction(append_df)
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)
dk.save_backtesting_prediction(append_df)
self.backtesting_fit_live_predictions(dk)
dk.fill_predictions(dataframe)
@ -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}. "