# source: https://raw.githubusercontent.com/mlsys-io/PortfolioBench/3f9d3b2097e074767ea741478568ebb2889f4949/strategy/AroonTrendStrategy.py
"""Strategy: Aroon Trend Strategy"""
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta

class Github_mlsys_io_PortfolioBench__AroonTrendStrategy__20260320_115648(IStrategy):
    timeframe = "5m"
    minimal_roi = {"0": 0.10, "180": 0.05}
    stoploss = -0.05
    startup_candle_count = 30

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        aroon = ta.AROON(dataframe, timeperiod=25)
        dataframe["aroon_up"] = aroon["aroonup"]
        dataframe["aroon_down"] = aroon["aroondown"]
        dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
        dataframe["ema50"] = ta.EMA(dataframe, timeperiod=50)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (dataframe["aroon_up"] > 70) & (dataframe["aroon_down"] < 30)
            & (dataframe["close"] > dataframe["ema50"])
            & (dataframe["rsi"] > 45) & (dataframe["rsi"] < 68)
            & (dataframe["volume"] > 0),
            "enter_long",
        ] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (dataframe["aroon_down"] > dataframe["aroon_up"]) | (dataframe["rsi"] > 73),
            "exit_long",
        ] = 1
        return dataframe
