Merge pull request #9339 from freqtrade/fix/returndf-bug

fix: bug in startup candle offset
This commit is contained in:
Matthias 2023-10-26 19:49:44 +02:00 committed by GitHub
commit b47ba8cfd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -296,8 +296,7 @@ class FreqaiDataDrawer:
f"for more than {len(dataframe.index)} candles.") f"for more than {len(dataframe.index)} candles.")
df_concat = pd.concat([hist_preds, new_pred], ignore_index=True, keys=hist_preds.keys()) df_concat = pd.concat([hist_preds, new_pred], ignore_index=True, keys=hist_preds.keys())
# remove last row because we will append that later in append_model_predictions()
df_concat = df_concat.iloc[:-1]
# any missing values will get zeroed out so users can see the exact # any missing values will get zeroed out so users can see the exact
# downtime in FreqUI # downtime in FreqUI
df_concat = df_concat.fillna(0) df_concat = df_concat.fillna(0)

View File

@ -179,10 +179,9 @@ def test_set_initial_return_values(mocker, freqai_conf):
hist_pred_df = freqai.dd.historic_predictions[pair] hist_pred_df = freqai.dd.historic_predictions[pair]
model_return_df = freqai.dd.model_return_values[pair] model_return_df = freqai.dd.model_return_values[pair]
assert (hist_pred_df['date_pred'].iloc[-1] == assert hist_pred_df['date_pred'].iloc[-1] == pd.Timestamp(end_x_plus_5)
pd.Timestamp(end_x_plus_5) - pd.Timedelta(days=1))
assert 'date_pred' in hist_pred_df.columns assert 'date_pred' in hist_pred_df.columns
assert hist_pred_df.shape[0] == 7 # Total rows: 5 from historic and 2 new zeros assert hist_pred_df.shape[0] == 8
# compare values in model_return_df with hist_pred_df # compare values in model_return_df with hist_pred_df
assert (model_return_df["value"].values == assert (model_return_df["value"].values ==
@ -234,9 +233,9 @@ def test_set_initial_return_values_warning(mocker, freqai_conf):
hist_pred_df = freqai.dd.historic_predictions[pair] hist_pred_df = freqai.dd.historic_predictions[pair]
model_return_df = freqai.dd.model_return_values[pair] model_return_df = freqai.dd.model_return_values[pair]
assert hist_pred_df['date_pred'].iloc[-1] == pd.Timestamp(end_x_plus_5) - pd.Timedelta(days=1) assert hist_pred_df['date_pred'].iloc[-1] == pd.Timestamp(end_x_plus_5)
assert 'date_pred' in hist_pred_df.columns assert 'date_pred' in hist_pred_df.columns
assert hist_pred_df.shape[0] == 9 # Total rows: 5 from historic and 4 new zeros assert hist_pred_df.shape[0] == 10
# compare values in model_return_df with hist_pred_df # compare values in model_return_df with hist_pred_df
assert (model_return_df["value"].values == hist_pred_df.tail( assert (model_return_df["value"].values == hist_pred_df.tail(