# source: https://raw.githubusercontent.com/KhalilGibrotha/freqtrade-antigravity-bot/1b44c8851e293a89eb9ef410c14b2280ac127ca1/freqtrade/user_data/strategies/RSIHyperoptStrategy.py
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib

class Github_KhalilGibrotha_freqtrade_antigravity_bot__RSIHyperoptStrategy__20260219_231337(IStrategy):
    INTERFACE_VERSION = 3
    
    # Minimal ROI - Will be optimized
    minimal_roi = { "0": 0.1 }
    
    # Stoploss - Will be optimized
    stoploss = -0.25
    
    timeframe = '5m'

    # Hyperopt parameters
    buy_rsi = IntParameter(10, 40, default=25, space="buy")
    sell_rsi = IntParameter(50, 90, default=55, space="sell")
    
    # Optional: Optimize stoploss and ROI (requires specific configuration, 
    # but we can set up the strategy class to handle it logic-wise if needed)

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe['rsi'] < self.buy_rsi.value) &
                (dataframe['volume'] > 0)
            ),
            'enter_long'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe['rsi'] > self.sell_rsi.value) &
                (dataframe['volume'] > 0)
            ),
            'exit_long'] = 1
        return dataframe
