Ensure base tf included in include_timeframes
This commit is contained in:
parent
e734b39929
commit
730fba956b
@ -233,3 +233,23 @@ def get_timerange_backtest_live_models(config: Config) -> str:
|
||||
dd = FreqaiDataDrawer(models_path, config)
|
||||
timerange = dd.get_timerange_from_live_historic_predictions()
|
||||
return timerange.timerange_str
|
||||
|
||||
|
||||
def ensure_base_tf_in_include_timeframes(config: Config) -> Config:
|
||||
"""
|
||||
Ensure that the base timeframe is included in the include_timeframes list
|
||||
:param config: Configuration dictionary
|
||||
|
||||
:return config: Configuration dictionary
|
||||
"""
|
||||
feature_parameters = config.get('freqai', {}).get('feature_parameters', {})
|
||||
include_timeframes = feature_parameters.get('include_timeframes', [])
|
||||
|
||||
if config['timeframe'] in include_timeframes:
|
||||
return config
|
||||
|
||||
include_timeframes = [config['timeframe']] + include_timeframes
|
||||
config.get('freqai', {}).get('feature_parameters', {}) \
|
||||
.update({**feature_parameters, 'include_timeframes': include_timeframes})
|
||||
|
||||
return config
|
||||
|
@ -148,9 +148,11 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
def load_freqAI_model(self) -> None:
|
||||
if self.config.get('freqai', {}).get('enabled', False):
|
||||
# Import here to avoid importing this if freqAI is disabled
|
||||
from freqtrade.freqai.utils import download_all_data_for_training
|
||||
from freqtrade.freqai.utils import (download_all_data_for_training,
|
||||
ensure_base_tf_in_include_timeframes)
|
||||
from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver
|
||||
self.freqai = FreqaiModelResolver.load_freqaimodel(self.config)
|
||||
self.config = ensure_base_tf_in_include_timeframes(self.config)
|
||||
self.freqai_info = self.config["freqai"]
|
||||
|
||||
# download the desired data in dry/live
|
||||
|
@ -9,7 +9,9 @@ from freqtrade.configuration import TimeRange
|
||||
from freqtrade.data.dataprovider import DataProvider
|
||||
from freqtrade.enums import RunMode
|
||||
from freqtrade.freqai.data_kitchen import FreqaiDataKitchen
|
||||
from freqtrade.freqai.utils import download_all_data_for_training, get_required_data_timerange
|
||||
from freqtrade.freqai.utils import (download_all_data_for_training,
|
||||
ensure_base_tf_in_include_timeframes,
|
||||
get_required_data_timerange)
|
||||
from freqtrade.optimize.backtesting import Backtesting
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.plugins.pairlistmanager import PairListManager
|
||||
@ -528,6 +530,19 @@ def test_start_set_train_queue(mocker, freqai_conf, caplog):
|
||||
)
|
||||
|
||||
|
||||
def test_base_tf_in_include_timeframes(mocker, freqai_conf):
|
||||
freqai_conf['timeframe'] = '5m'
|
||||
freqai_conf['freqai']['feature_parameters'].update({
|
||||
'include_timeframes': ['15m', '1h']
|
||||
})
|
||||
updated_conf = ensure_base_tf_in_include_timeframes(freqai_conf)
|
||||
assert updated_conf['freqai']['feature_parameters']['include_timeframes'] == [
|
||||
'5m', '15m', '1h',
|
||||
]
|
||||
last_conf = ensure_base_tf_in_include_timeframes(updated_conf)
|
||||
assert last_conf == updated_conf
|
||||
|
||||
|
||||
def test_get_required_data_timerange(mocker, freqai_conf):
|
||||
time_range = get_required_data_timerange(freqai_conf)
|
||||
assert (time_range.stopts - time_range.startts) == 177300
|
||||
|
Loading…
Reference in New Issue
Block a user