current_profit: float,
**kwargs,
):
- dataframe, _ = self.dp.get_analyzed_dataframe(
- pair=pair, timeframe=self.timeframe
- )
+ df, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe)
- last_candle = dataframe.iloc[-1].squeeze()
+ last_candle = df.iloc[-1].squeeze()
if last_candle["DI_catch"] == 0:
return "outlier_detected"
):
return False
- df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
+ df, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe)
last_candle = df.iloc[-1].squeeze()
if (side == "long" and rate > last_candle["close"] * (1 + 0.0025)) or (
side == "short" and rate < last_candle["close"] * (1 - 0.0025)
)
-def top_percent_change(dataframe: DataFrame, length: int) -> Series:
+def top_percent_change_open(dataframe: DataFrame, length: int) -> Series:
"""
- Percentage change of the current close relative from the range maximum open price
+ Percentage change of the current close relative to the maximum open price
+ over the lookback period.
:param dataframe: DataFrame The original OHLC dataframe
:param length: int The period length to look back
"""
return ((dataframe["close"] - open_max) / open_max).fillna(0.0)
+def top_percent_change(dataframe: DataFrame, length: int) -> Series:
+ """
+ Percentage change of the current close relative to the maximum close price
+ over the lookback period.
+ :param dataframe: DataFrame The original OHLC dataframe
+ :param length: int The period length to look back (0 = previous candle)
+ """
+ if length == 0:
+ previous_close = dataframe["close"].shift(1)
+ return ((dataframe["close"] - previous_close) / previous_close).fillna(0.0)
+ else:
+ close_max = dataframe["close"].rolling(length).max()
+ return ((dataframe["close"] - close_max) / close_max).fillna(0.0)
+
+
def chaikin_mf(df: DataFrame, periods=20) -> Series:
close = df["close"]
low = df["low"]