import unittest

from kraken_bot.models import Candle, Side
from kraken_bot.strategies import SMACrossoverStrategy, build_strategy


def candle(close: float) -> Candle:
    return Candle(0, close, close, close, close, close, 1.0, 1)


class StrategyTests(unittest.TestCase):
    def test_build_strategy_rejects_unknown_strategy(self) -> None:
        with self.assertRaisesRegex(ValueError, "Unknown strategy"):
            build_strategy("missing")

    def test_sma_crossover_can_emit_buy(self) -> None:
        closes = [10, 10, 10, 10, 8, 13]
        strategy = SMACrossoverStrategy(short_period=2, long_period=4)
        signal = strategy.generate([candle(close) for close in closes])
        self.assertIs(signal.side, Side.BUY)


if __name__ == "__main__":
    unittest.main()
