Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented a parameter for skipping errors during model training in the backtest process #10098

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

xsa-dev
Copy link
Contributor

@xsa-dev xsa-dev commented Apr 18, 2024

Summary

In case of any data disruptions related to a coin, currently, a hard exception occurs, interrupting the backtesting and limiting the completion of backtesting for the FreqAI strategy with other coins. To bypass this, it was suggested to use an exception skipping parameter as a warning, during which the exception is ignored during backtesting, allowing the backtesting to continue. In a separate case (with another parameter), resolving this issue may involve additional data preprocessing, which is not included in this feature's development.

Solve the issue: #9671

Quick changelog

  • new parameter warn_exceptions_on_backtest_only to config_examples/config_freqai.example.json in config.freqai
  • modify backtesting logic in freqtrade/freqai/freqai_interface.py

What's new?

We added an exception skipping parameter to handle data disruptions during backtesting, letting the FreqAI strategy proceed across coins even when exceptions occur, and there's potential for further data preprocessing to tackle such issues later on.

@coveralls
Copy link

coveralls commented Apr 18, 2024

Coverage Status

coverage: 94.719% (+0.06%) from 94.656%
when pulling 62c64e2 on xsa-dev:Error-Skipping
into 8e5c574 on freqtrade:develop.

@robcaulk robcaulk self-assigned this Apr 18, 2024
@xmatthias xmatthias added the freqAI Issues and PR's related to freqAI label Apr 18, 2024
freqtrade/freqai/freqai_interface.py Outdated Show resolved Hide resolved
freqtrade/freqai/freqai_interface.py Show resolved Hide resolved
@xsa-dev
Copy link
Contributor Author

xsa-dev commented Apr 23, 2024

Suggested edit:

diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py
index 224b9dbe1..ae17c5940 100644
--- a/freqtrade/freqai/freqai_interface.py
+++ b/freqtrade/freqai/freqai_interface.py
@@ -5,7 +5,7 @@ from abc import ABC, abstractmethod
 from collections import deque
 from datetime import datetime, timezone
 from pathlib import Path
-from typing import Any, Dict, List, Literal, Optional, Tuple, Union
+from typing import Any, Dict, List, Literal, Optional, Tuple
 
 import datasieve.transforms as ds
 import numpy as np
@@ -108,7 +108,7 @@ class IFreqaiModel(ABC):
         self.data_provider: Optional[DataProvider] = None
         self.max_system_threads = max(int(psutil.cpu_count() * 2 - 2), 1)
         self.can_short = True  # overridden in start() with strategy.can_short
-        self.model: Union[Any, None] = None
+        self.model: Any = None
         if self.ft_params.get('principal_component_analysis', False) and self.continual_learning:
             self.ft_params.update({'principal_component_analysis': False})
             logger.warning('User tried to use PCA with continual learning. Deactivating PCA.')
@@ -258,7 +258,7 @@ class IFreqaiModel(ABC):
                     self.dd.save_metric_tracker_to_disk()
 
 
-    def _train_model(self, dataframe_train, pair, dk, tr_backtest) -> Union[Any, None]:
+    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)

@xsa-dev xsa-dev changed the title implemented a parameter for skipping errors during model training in the backtest process [WIP] implemented a parameter for skipping errors during model training in the backtest process Apr 25, 2024
@xsa-dev xsa-dev requested a review from robcaulk April 25, 2024 18:21
Copy link
Contributor Author

@xsa-dev xsa-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@xsa-dev xsa-dev changed the title [WIP] implemented a parameter for skipping errors during model training in the backtest process implemented a parameter for skipping errors during model training in the backtest process Apr 25, 2024
@xsa-dev
Copy link
Contributor Author

xsa-dev commented Apr 28, 2024

close #10145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
freqAI Issues and PR's related to freqAI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants