chore: try to keep startup_candle_count behaving the same as a normal FT strat

This commit is contained in:
robcaulk 2023-11-20 09:13:01 +01:00
parent 21a5abf25d
commit d52936fd42
2 changed files with 12 additions and 4 deletions

View File

@ -332,14 +332,15 @@ class DataProvider:
if not freqai_config.get('enabled', False):
return self._config.get('startup_candle_count', 0)
else:
startup_candles = self._config.get('startup_candle_count', 0)
indicator_periods = freqai_config['feature_parameters']['indicator_periods_candles']
# make sure the startupcandles is at least the set maximum indicator periods
needed_candles = max(indicator_periods)
self._config['startup_candle_count'] = max(startup_candles, max(indicator_periods))
tf_seconds = timeframe_to_seconds(timeframe)
train_candles = 0
if add_train_candles:
train_candles = freqai_config['train_period_days'] * 86400 / tf_seconds
total_candles = int(needed_candles + train_candles)
total_candles = int(self._config['startup_candle_count'] + train_candles)
logger.info(f'Increasing startup_candle_count for freqai to {total_candles}')
return total_candles

View File

@ -147,7 +147,9 @@ class Backtesting:
if self.config.get('freqai', {}).get('enabled', False):
# For FreqAI, increase the required_startup to includes the training data
self.required_startup = self.dataprovider.get_required_startup(self.timeframe)
self.freqai_startup_candles = self.dataprovider.get_required_startup(
self.timeframe
)
# Add maximum startup candle count to configuration for informative pairs support
self.config['startup_candle_count'] = self.required_startup
@ -234,12 +236,17 @@ class Backtesting:
"""
self.progress.init_step(BacktestState.DATALOAD, 1)
if self.config.get('freqai', {}).get('enabled', False):
startup_candle_count = self.freqai_startup_candles
else:
startup_candle_count = self.config['startup_candle_count']
data = history.load_data(
datadir=self.config['datadir'],
pairs=self.pairlists.whitelist,
timeframe=self.timeframe,
timerange=self.timerange,
startup_candles=self.config['startup_candle_count'],
startup_candles=startup_candle_count,
fail_without_data=True,
data_format=self.config['dataformat_ohlcv'],
candle_type=self.config.get('candle_type_def', CandleType.SPOT)