mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 04:03:55 +00:00
docstring and tests
This commit is contained in:
parent
2c9b765953
commit
1ef1fc269e
|
@ -31,6 +31,8 @@ def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
||||||
:param ffill: Forwardfill missing values - optional but usually required
|
:param ffill: Forwardfill missing values - optional but usually required
|
||||||
:param append_timeframe: Rename columns by appending timeframe.
|
:param append_timeframe: Rename columns by appending timeframe.
|
||||||
:param date_column: A custom date column name.
|
:param date_column: A custom date column name.
|
||||||
|
:param suffix: A string suffix to add at the end of the informative columns. If specified,
|
||||||
|
append_timeframe must be false.
|
||||||
:return: Merged dataframe
|
:return: Merged dataframe
|
||||||
:raise: ValueError if the secondary timeframe is shorter than the dataframe timeframe
|
:raise: ValueError if the secondary timeframe is shorter than the dataframe timeframe
|
||||||
"""
|
"""
|
||||||
|
@ -57,7 +59,7 @@ def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
||||||
date_merge = f'date_merge_{timeframe_inf}'
|
date_merge = f'date_merge_{timeframe_inf}'
|
||||||
informative.columns = [f"{col}_{timeframe_inf}" for col in informative.columns]
|
informative.columns = [f"{col}_{timeframe_inf}" for col in informative.columns]
|
||||||
|
|
||||||
elif suffix:
|
elif suffix and not append_timeframe:
|
||||||
date_merge = f'date_merge_{suffix}'
|
date_merge = f'date_merge_{suffix}'
|
||||||
informative.columns = [f"{col}_{suffix}" for col in informative.columns]
|
informative.columns = [f"{col}_{suffix}" for col in informative.columns]
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,29 @@ 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_suffix():
|
||||||
|
data = generate_test_data('15m', 20)
|
||||||
|
informative = generate_test_data('1h', 20)
|
||||||
|
|
||||||
|
result = merge_informative_pair(data, informative, '15m', '1h',
|
||||||
|
append_timeframe=False, suffix="suf")
|
||||||
|
|
||||||
|
assert 'date' in result.columns
|
||||||
|
assert result['date'].equals(data['date'])
|
||||||
|
assert 'date_suf' in result.columns
|
||||||
|
|
||||||
|
assert 'open_suf' in result.columns
|
||||||
|
assert 'open_1h' not in result.columns
|
||||||
|
|
||||||
|
|
||||||
|
def test_merge_informative_pair_suffix_append_timeframe():
|
||||||
|
data = generate_test_data('15m', 20)
|
||||||
|
informative = generate_test_data('1h', 20)
|
||||||
|
|
||||||
|
with pytest.raises(ValueError, match=r"You can not specify `append_timeframe` .*"):
|
||||||
|
merge_informative_pair(data, informative, '15m', '1h', suffix="suf")
|
||||||
|
|
||||||
|
|
||||||
def test_stoploss_from_open():
|
def test_stoploss_from_open():
|
||||||
open_price_ranges = [
|
open_price_ranges = [
|
||||||
[0.01, 1.00, 30],
|
[0.01, 1.00, 30],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user