Don't hard-fail merge if there's no informative data
This commit is contained in:
@@ -45,10 +45,13 @@ def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
|||||||
elif minutes < minutes_inf:
|
elif minutes < minutes_inf:
|
||||||
# Subtract "small" timeframe so merging is not delayed by 1 small candle
|
# Subtract "small" timeframe so merging is not delayed by 1 small candle
|
||||||
# Detailed explanation in https://github.com/freqtrade/freqtrade/issues/4073
|
# Detailed explanation in https://github.com/freqtrade/freqtrade/issues/4073
|
||||||
informative['date_merge'] = (
|
if not informative.empty:
|
||||||
informative[date_column] + pd.to_timedelta(minutes_inf, 'm') -
|
informative['date_merge'] = (
|
||||||
pd.to_timedelta(minutes, 'm')
|
informative[date_column] + pd.to_timedelta(minutes_inf, 'm') -
|
||||||
)
|
pd.to_timedelta(minutes, 'm')
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
informative['date_merge'] = informative[date_column]
|
||||||
else:
|
else:
|
||||||
raise ValueError("Tried to merge a faster timeframe to a slower timeframe."
|
raise ValueError("Tried to merge a faster timeframe to a slower timeframe."
|
||||||
"This would create new rows, and can throw off your regular indicators.")
|
"This would create new rows, and can throw off your regular indicators.")
|
||||||
|
|||||||
@@ -96,6 +96,30 @@ def test_merge_informative_pair_lower():
|
|||||||
merge_informative_pair(data, informative, '1h', '15m', ffill=True)
|
merge_informative_pair(data, informative, '1h', '15m', ffill=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_merge_informative_pair_empty():
|
||||||
|
data = generate_test_data('1h', 40)
|
||||||
|
informative = pd.DataFrame(columns=data.columns)
|
||||||
|
|
||||||
|
result = merge_informative_pair(data, informative, '1h', '2h', ffill=True)
|
||||||
|
assert result['date'].equals(data['date'])
|
||||||
|
|
||||||
|
assert list(result.columns) == [
|
||||||
|
'date',
|
||||||
|
'open',
|
||||||
|
'high',
|
||||||
|
'low',
|
||||||
|
'close',
|
||||||
|
'volume',
|
||||||
|
'date_2h',
|
||||||
|
'open_2h',
|
||||||
|
'high_2h',
|
||||||
|
'low_2h',
|
||||||
|
'close_2h',
|
||||||
|
'volume_2h'
|
||||||
|
]
|
||||||
|
assert result['volume_2h'].isnull().all()
|
||||||
|
|
||||||
|
|
||||||
def test_merge_informative_pair_suffix():
|
def test_merge_informative_pair_suffix():
|
||||||
data = generate_test_data('15m', 20)
|
data = generate_test_data('15m', 20)
|
||||||
informative = generate_test_data('1h', 20)
|
informative = generate_test_data('1h', 20)
|
||||||
|
|||||||
Reference in New Issue
Block a user