"""
信号层抽象接口（通用）

只提供抽象基类，具体信号生成器在strategies/shared/signals/
"""

from abc import ABC, abstractmethod
from typing import List, Optional, Any
import pandas as pd


class SignalGenerator(ABC):
    """
    信号生成器抽象基类
    
    所有信号生成器必须实现generate方法
    """
    
    mode: str = "base"
    
    def __init__(self, **params):
        """初始化信号生成器参数"""
        self._params = params
    
    @abstractmethod
    def generate(self, factor_data: pd.DataFrame) -> pd.DataFrame:
        """
        生成交易信号
        
        Args:
            factor_data: 因子数据DataFrame
            
        Returns:
            包含'signal'列的DataFrame
        """
        pass
    
    def validate_factor_data(self, factor_data: pd.DataFrame) -> bool:
        """验证因子数据是否有效"""
        if factor_data.empty:
            return False
        
        if 'signal' in factor_data.columns:
            print("Warning: factor_data already contains 'signal' column")
        
        return True
    
    def __repr__(self) -> str:
        params_str = ', '.join([f"{k}={v}" for k, v in self._params.items()])
        return f"{self.__class__.__name__}({params_str})"


# 导出抽象接口
__all__ = ['SignalGenerator']