# source: https://raw.githubusercontent.com/vigoferrel/qbtc-unified/ef7ffc8f45cc7ab041884cd0c08a2043acc1f0cb/freqtrade_qbtc/strategies/QBTCBasic.py
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement

"""
Estrategia básica RSI para pruebas - debe generar trades
"""

from pandas import DataFrame
from freqtrade.strategy import (
    IStrategy,
    IntParameter
)
import talib.abstract as ta


class Github_vigoferrel_qbtc_unified__QBTCBasic__20251009_202533(IStrategy):
    """
    Estrategia básica solo con RSI - garantiza trades
    """
    
    INTERFACE_VERSION = 3
    
    # ROI y Stoploss muy permisivos
    minimal_roi = {
        "0": 0.05,      # 5% profit target
        "60": 0.02,     # 2% después de 1h
        "120": 0.01,    # 1% después de 2h
    }
    
    stoploss = -0.03  # 3% stop loss
    
    timeframe = '15m'
    startup_candle_count: int = 30
    
    # Parámetros muy amplios para garantizar trades
    buy_rsi = IntParameter(10, 50, default=40, space="buy", optimize=True)
    sell_rsi = IntParameter(50, 90, default=60, space="sell", optimize=True)
    
    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),
            'enter_long'
        ] = 1
        
        return dataframe
    
    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (dataframe['rsi'] > self.sell_rsi.value),
            'exit_long'
        ] = 1
        
        return dataframe
