# source: https://raw.githubusercontent.com/vntrevx/NFI_BackTestEngine/c45a7a5e2ca147d95a9ed35f381e5bd7bdff9426/benchmarks/reference/strategies/SignalProgramContract.py
# directory_url: https://github.com/vntrevx/NFI_BackTestEngine/blob/main/benchmarks/reference/strategies/
# User: vntrevx
# Repository: NFI_BackTestEngine
# --------------------from freqtrade.strategy import IStrategy


class Github_vntrevx_NFI_BackTestEngine__SignalProgramContract__20260816_085414(IStrategy):
    timeframe = "5m"

    def populate_entry_trend(self, dataframe, metadata):
        dataframe.loc[:, ["enter_long", "enter_short"]] = (0, 0)
        positive = dataframe["score"] > 0
        dataframe.loc[positive, "enter_long"] = 1
        dataframe.loc[dataframe["score"] >= 2, "enter_long"] = 0
        dataframe["enter_short"] = (dataframe["score"] < 0).astype(int)
        return dataframe

    def populate_exit_trend(self, dataframe, metadata):
        dataframe.loc[:, ["exit_long", "exit_short"]] = 0
        dataframe.loc[
            (dataframe["enter_long"] == 0) & (dataframe["score"] > 1),
            "exit_long",
        ] = 1
        dataframe.loc[dataframe["exit_mask"], "exit_short"] = 1
        return dataframe
