start frequi with historical data if available

This commit is contained in:
Robert Caulk 2022-08-05 18:27:05 +02:00
parent 29b7b014e5
commit a3799c4d5d
1 changed files with 25 additions and 11 deletions

View File

@ -229,6 +229,20 @@ class FreqaiDataDrawer:
# dynamic df returned to strategy and plotted in frequi
mrv_df = self.model_return_values[pair] = pd.DataFrame()
# if user reused `idenfitier` in config and has historical predictions collected, loadthem
# so that frequi remains uninterrupted after a crash
hist_df = self.historic_predictions
if pair in hist_df:
len_diff = len(hist_df[pair].index) - len(pred_df.index)
if len_diff < 0:
df_concat = pd.concat([pred_df.iloc[:abs(len_diff)], hist_df[pair]],
ignore_index=True, keys=hist_df[pair].keys())
else:
df_concat = hist_df[pair].tail(len(pred_df.index))
df_concat = df_concat.fillna(0)
self.model_return_values[pair] = df_concat
else:
for label in dk.label_list:
mrv_df[label] = pred_df[label]
mrv_df[f"{label}_mean"] = dk.data["labels_mean"][label]