refactor: align naming for clean_ohlcv_dataframe
This commit is contained in:
@@ -59,14 +59,14 @@ def ohlcv_to_dataframe(
|
||||
|
||||
|
||||
def clean_ohlcv_dataframe(
|
||||
data: DataFrame, timeframe: str, pair: str, *, fill_missing: bool, drop_incomplete: bool
|
||||
dataframe: DataFrame, timeframe: str, pair: str, *, fill_missing: bool, drop_incomplete: bool
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Cleanse a OHLCV dataframe by
|
||||
* Grouping it by date (removes duplicate tics)
|
||||
* dropping last candles if requested
|
||||
* Filling up missing data (if requested)
|
||||
:param data: DataFrame containing candle (OHLCV) data.
|
||||
:param dataframe: DataFrame containing candle (OHLCV) data.
|
||||
:param timeframe: timeframe (e.g. 5m). Used to fill up eventual missing data
|
||||
:param pair: Pair this data is for (used to warn if fillup was necessary)
|
||||
:param fill_missing: fill up missing candles with 0 candles
|
||||
@@ -75,7 +75,7 @@ def clean_ohlcv_dataframe(
|
||||
:return: DataFrame
|
||||
"""
|
||||
# group by index and aggregate results to eliminate duplicate ticks
|
||||
data = data.groupby(by="date", as_index=False, sort=True).agg(
|
||||
dataframe = dataframe.groupby(by="date", as_index=False, sort=True).agg(
|
||||
{
|
||||
"open": "first",
|
||||
"high": "max",
|
||||
@@ -86,13 +86,13 @@ def clean_ohlcv_dataframe(
|
||||
)
|
||||
# eliminate partial candle
|
||||
if drop_incomplete:
|
||||
data.drop(data.tail(1).index, inplace=True)
|
||||
dataframe.drop(dataframe.tail(1).index, inplace=True)
|
||||
logger.debug("Dropping last candle")
|
||||
|
||||
if fill_missing:
|
||||
return ohlcv_fill_up_missing_data(data, timeframe, pair)
|
||||
return ohlcv_fill_up_missing_data(dataframe, timeframe, pair)
|
||||
else:
|
||||
return data
|
||||
return dataframe
|
||||
|
||||
|
||||
def ohlcv_fill_up_missing_data(dataframe: DataFrame, timeframe: str, pair: str) -> DataFrame:
|
||||
|
||||
Reference in New Issue
Block a user