# source: https://raw.githubusercontent.com/remiotore/ccxt-freqtrade/44beaeb6a420cd8e9f2e4ea93e11d6cfa192ee03/strategies/ema_strat_15m_prod.py

from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame

import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


class Github_remiotore_ccxt_freqtrade__ema_strat_15m_prod__20260111_210550(IStrategy):
    stoploss = -0.2
    timeframe = "15m"

    order_types = {
        "buy": "limit",
        "sell": "limit",
        "emergencysell": "market",
        "stoploss": "market",
        "stoploss_on_exchange": True,
        "stoploss_on_exchange_interval": 60,
        "stoploss_on_exchange_limit_ratio": 0.99,
    }

    minimal_roi = {
        "60": 0.6,
        "120": 0.05,
        "600": 0.035,
        "630": 0.012,
        "0": 0.09,
    }

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe["EMA_QUICK"] = ta.SMA(dataframe, timeperiod=7)
        dataframe["EMA_SLOW"] = ta.SMA(dataframe, timeperiod=21)

        return dataframe

    def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe["close"] > dataframe["EMA_QUICK"])
                & (dataframe["EMA_QUICK"] > dataframe["EMA_SLOW"])
            ),
            "buy",
        ] = 1

        return dataframe

    def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[(), "sell",] = 1
        return dataframe
