from src.core.strategy import Signal
from src.utils.logger import log


class DemoPingPongStrategy:
    """
    Estrategia DEMO para testear UI.
    Genera BUY / SELL cada N ticks del loop.
    """

    def __init__(self, period: int = 3):
        self.period = period
        self.name = "demo"
        self.data = None
        self.tick = 0   # 👈 CLAVE

    def set_data(self, df):
        self.data = df

    def generate_signal(self, idx: int) -> Signal:
        self.tick += 1

        log.info(f"[PINGPONG] tick={self.tick}")

        if self.tick == 3:
            log.info("[PINGPONG] BUY signal")
            return Signal.BUY

        if self.tick == 5:
            log.info("[PINGPONG] SELL signal")
            self.tick = 0
            return Signal.SELL

        return Signal.HOLD

