Merge pull request #7391 from wagnercosta/fixBTfreqaiV2

Fix FreaqAI backtesting - startup_candle_count bug
This commit is contained in:
Robert Caulk 2022-09-10 21:53:00 +02:00 committed by GitHub
commit 73e122ad10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -470,10 +470,17 @@ class FreqaiDataKitchen:
) -> DataFrame:
"""
Function which takes the backtesting time range and
remove training data from dataframe
remove training data from dataframe, keeping only the
startup_candle_count candles
"""
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, :]