diff --git a/freqtrade/strategy/strategy_helper.py b/freqtrade/strategy/strategy_helper.py index 34d54f9a4..1292b65b5 100644 --- a/freqtrade/strategy/strategy_helper.py +++ b/freqtrade/strategy/strategy_helper.py @@ -98,14 +98,15 @@ def merge_informative_pair( # We can fill these with the last available informative candle before the start date # while still avoiding lookahead bias - as only past data is used. first_valid_idx = dataframe[date_merge].first_valid_index() - first_valid_date_merge = dataframe.at[first_valid_idx, date_merge] - matching_informative_raws = informative[ - informative[date_merge] < first_valid_date_merge - ] - if not matching_informative_raws.empty: - dataframe.loc[: first_valid_idx - 1] = dataframe.loc[: first_valid_idx - 1].fillna( - matching_informative_raws.iloc[-1] - ) + if first_valid_idx: + first_valid_date_merge = dataframe.at[first_valid_idx, date_merge] + matching_informative_raws = informative[ + informative[date_merge] < first_valid_date_merge + ] + if not matching_informative_raws.empty: + dataframe.loc[: first_valid_idx - 1] = dataframe.loc[ + : first_valid_idx - 1 + ].fillna(matching_informative_raws.iloc[-1]) else: dataframe = pd.merge( dataframe, informative, left_on="date", right_on=date_merge, how="left"