add suffix parameter
This commit is contained in:
parent
c08c82bc40
commit
2c9b765953
@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
from freqtrade.exchange import timeframe_to_minutes
|
from freqtrade.exchange import timeframe_to_minutes
|
||||||
@ -6,7 +8,8 @@ from freqtrade.exchange import timeframe_to_minutes
|
|||||||
def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
||||||
timeframe: str, timeframe_inf: str, ffill: bool = True,
|
timeframe: str, timeframe_inf: str, ffill: bool = True,
|
||||||
append_timeframe: bool = True,
|
append_timeframe: bool = True,
|
||||||
date_column: str = 'date') -> pd.DataFrame:
|
date_column: str = 'date',
|
||||||
|
suffix: Optional[str] = None) -> pd.DataFrame:
|
||||||
"""
|
"""
|
||||||
Correctly merge informative samples to the original dataframe, avoiding lookahead bias.
|
Correctly merge informative samples to the original dataframe, avoiding lookahead bias.
|
||||||
|
|
||||||
@ -50,10 +53,17 @@ def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
|||||||
|
|
||||||
# Rename columns to be unique
|
# Rename columns to be unique
|
||||||
date_merge = 'date_merge'
|
date_merge = 'date_merge'
|
||||||
if append_timeframe:
|
if append_timeframe and not suffix:
|
||||||
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:
|
||||||
|
date_merge = f'date_merge_{suffix}'
|
||||||
|
informative.columns = [f"{col}_{suffix}" for col in informative.columns]
|
||||||
|
|
||||||
|
elif suffix and append_timeframe:
|
||||||
|
raise ValueError("You can not specify `append_timeframe` as True and a `suffix`.")
|
||||||
|
|
||||||
# Combine the 2 dataframes
|
# Combine the 2 dataframes
|
||||||
# all indicators on the informative sample MUST be calculated before this point
|
# all indicators on the informative sample MUST be calculated before this point
|
||||||
if ffill:
|
if ffill:
|
||||||
|
Loading…
Reference in New Issue
Block a user