From d9b79d94e46fab456e4a0699ad372f2839a29b33 Mon Sep 17 00:00:00 2001 From: robcaulk Date: Tue, 7 Jun 2022 20:57:10 +0200 Subject: [PATCH] increase candle update flexibility to allow long sequential trainings that may last more than one candle --- freqtrade/freqai/data_kitchen.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqai/data_kitchen.py b/freqtrade/freqai/data_kitchen.py index fafeda49d..11c9142a6 100644 --- a/freqtrade/freqai/data_kitchen.py +++ b/freqtrade/freqai/data_kitchen.py @@ -866,15 +866,22 @@ class FreqaiDataKitchen: for pair in self.all_pairs: for tf in self.freqai_config.get('timeframes'): + # check if newest candle is already appended + df_dp = strategy.dp.get_pair_dataframe(pair, tf) if ( str(history_data[pair][tf].iloc[-1]['date']) == - str(strategy.dp.get_pair_dataframe(pair, tf).iloc[-1:]['date'].iloc[-1]) + str(df_dp.iloc[-1:]['date'].iloc[-1]) ): continue + + index = df_dp.loc[ + df_dp['date'] == + history_data[pair][tf].iloc[-1]['date'] + ].index[0] + 1 history_data[pair][tf] = pd.concat( [history_data[pair][tf], - strategy.dp.get_pair_dataframe(pair, tf).iloc[-1:]], + strategy.dp.get_pair_dataframe(pair, tf).iloc[index:]], ignore_index=True, axis=0 )