fix backtesting freqai startup candles bug

This commit is contained in:
Wagner Costa Santos 2022-09-10 10:27:17 -03:00
parent f4f2884a66
commit 79985fda01

View File

@ -468,8 +468,14 @@ class FreqaiDataKitchen:
Function which takes the backtesting time range and
remove training data from dataframe
"""
startup_candle_count = self.config.get('startup_candle_count', 0)
tf = self.config['timeframe']
tr = self.config["timerange"]
backtesting_timerange = TimeRange.parse_timerange(tr)
if startup_candle_count > 0 and backtesting_timerange:
backtesting_timerange.subtract_start(timeframe_to_seconds(tf) * startup_candle_count)
start = datetime.fromtimestamp(backtesting_timerange.startts, tz=timezone.utc)
df = self.return_dataframe
df = df.loc[df["date"] >= start, :]