mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-15 20:31:43 +00:00
fix: handle case where informative does not overlap with the main data
This commit is contained in:
@@ -98,14 +98,15 @@ def merge_informative_pair(
|
|||||||
# We can fill these with the last available informative candle before the start date
|
# 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.
|
# while still avoiding lookahead bias - as only past data is used.
|
||||||
first_valid_idx = dataframe[date_merge].first_valid_index()
|
first_valid_idx = dataframe[date_merge].first_valid_index()
|
||||||
first_valid_date_merge = dataframe.at[first_valid_idx, date_merge]
|
if first_valid_idx:
|
||||||
matching_informative_raws = informative[
|
first_valid_date_merge = dataframe.at[first_valid_idx, date_merge]
|
||||||
informative[date_merge] < first_valid_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(
|
if not matching_informative_raws.empty:
|
||||||
matching_informative_raws.iloc[-1]
|
dataframe.loc[: first_valid_idx - 1] = dataframe.loc[
|
||||||
)
|
: first_valid_idx - 1
|
||||||
|
].fillna(matching_informative_raws.iloc[-1])
|
||||||
else:
|
else:
|
||||||
dataframe = pd.merge(
|
dataframe = pd.merge(
|
||||||
dataframe, informative, left_on="date", right_on=date_merge, how="left"
|
dataframe, informative, left_on="date", right_on=date_merge, how="left"
|
||||||
|
|||||||
Reference in New Issue
Block a user