from enum import IntEnum
from typing import NotRequired, TypeVar, Generic

from ldnode.calculator.schemas import (
    ScreenParameters as BaseScreenModel,
    STKScreenParameters as STKScreenModel, 
    CBScreenParameters as CBScreenModel,
    ETFScreenParameters as ETFScreenModel,
)
from .common import TaskBaseParameters


class NullScoreType(IntEnum):
    """
    是否包含score为null的记录
    """
    EXCLUDE = 0  # 排除null值
    INCLUDE_LAST = 1  # 包含null值且null值排在最后
    

SCREEN_MODEL = TypeVar('SCREEN_MODEL', bound=BaseScreenModel)
class BaseScreenParameters(TaskBaseParameters, Generic[SCREEN_MODEL]):
    """ 选股/债参数 """
    strategy_configs: dict[str, SCREEN_MODEL] # 策略ID: 策略配置
    trade_date: NotRequired[str] # 交易日期
    hold_securities: NotRequired[list[str]] # 持仓证券
    show_all_data: NotRequired[bool] # 返回所有截面数据，否则只返回['code', 'score', 'rank', '_weight', 'selected']
    null_score_type: NotRequired[NullScoreType] # 是否包含score为null的记录
    

class STKScreenParameters(BaseScreenParameters[STKScreenModel]):
    """ 选股参数 """
    

class CBScreenParameters(BaseScreenParameters[CBScreenModel]):
    """ 选债参数 """


class ETFScreenParameters(BaseScreenParameters[ETFScreenModel]):
    """ 选基参数 """
