from typing import TypedDict, TypeVar, Generic

from ldnode.calculator.schemas import (
    BacktestParameters,
    CBBacktestParameters,
    STKBacktestParameters,
    ETFBacktestParameters,
)
from .common import TaskBaseParameters


BACKTEST_MODEL = TypeVar('BACKTEST_MODEL', bound=BacktestParameters)
class BaseBinningParameters(TaskBaseParameters, Generic[BACKTEST_MODEL]):
    """ 分箱回测参数 """
    strategy_config: BACKTEST_MODEL # 策略配置
    bins: int # 分箱数


class CBBinningParameters(BaseBinningParameters[CBBacktestParameters]):
    """ 转债分箱回测参数 """


class STKBinningParameters(BaseBinningParameters[STKBacktestParameters]):
    """ 股票分箱回测参数 """
    

class ETFBinningParameters(BaseBinningParameters[ETFBacktestParameters]):
    """ 基金分箱回测参数 """


class BinningResponse(TypedDict):
    """ 转债分箱回测响应 """
    ic_mean: float # 相关性均值
    ir: float # 信息比率
    return_df: bytes # 收益率曲线
    corr_df: bytes # 相关性