from candlestick.patterns.candlestick_finder import CandlestickFinder


class Hammer(CandlestickFinder):
    def __init__(self, target=None):
        super().__init__(self.get_class_name(), 1, target=target)

    def logic(self, idx):
        candle = self.data.iloc[idx]

        close = candle[self.close_column]
        open = candle[self.open_column]
        high = candle[self.high_column]
        low = candle[self.low_column]

        return (
            ((high - low) > 3 * (open - close))
            and ((close - low) / (0.001 + high - low) > 0.6)
            and ((open - low) / (0.001 + high - low) > 0.6)
        )
