#!/usr/bin/env python3
"""
SignalGenerators - 可替换的策略信号生成器包

使用方式：
    from signal_generators import create_generator

    gen = create_generator("ema_macd")
    signal = gen.analyze(bars, params={"ema_short": 9, "ema_long": 21})
"""
from .base import BaseSignalGenerator
from .ema_macd_signal import EMAMacdSignalGenerator


def create_generator(strategy_type: str = "ema_macd", params: dict = None) -> BaseSignalGenerator:
    """统一工厂函数：根据策略类型创建信号生成器"""
    if strategy_type in ("ema_macd", "ema", "default"):
        return EMAMacdSignalGenerator(params)
    elif strategy_type in ("wyckoff", "wyck"):
        from .wyckoff_signal import WyckoffSignalGenerator
        return WyckoffSignalGenerator(params)
    elif strategy_type in ("composite", "multi", "hybrid"):
        from .composite_signal import CompositeSignalGenerator
        return CompositeSignalGenerator(params)
    elif strategy_type in ("adx_breakout", "adx"):
        from .adx_breakout_signal import ADXBreakoutSignal
        return ADXBreakoutSignal(params)
    elif strategy_type in ("rsi_extreme", "rsi"):
        from .rsi_extreme_signal import RSIExtremeSignal
        return RSIExtremeSignal(params)
    elif strategy_type in ("boll_band", "bb", "boll"):
        from .boll_band_signal import BollBandSignal
        return BollBandSignal(params)
    elif strategy_type in ("pullback_fade", "pullback"):
        from .pullback_fade_signal import PullbackFadeSignal
        return PullbackFadeSignal(params)
    elif strategy_type in ("grid_osc", "grid"):
        from .grid_osc_signal import GridOscSignal
        return GridOscSignal(params)
    elif strategy_type in ("key_level"):
        from .key_level_signal import KeyLevelSignal
        return KeyLevelSignal(params)
    else:
        raise ValueError(f"Unknown or unimplemented strategy type: {strategy_type}")


__all__ = [
    "BaseSignalGenerator",
    "EMAMacdSignalGenerator",
    "create_generator",
]
