# This file is auto-generated by generate_models.py
# This file may be manually edited after generation
# The file has been formatted using isort and black

from typing import Any, ClassVar, Dict, List

from sqlalchemy import Column, PrimaryKeyConstraint, text

from tushare_models.core import Base, Date, DateTime, Float, Integer, String
from tushare_models.core.dialect_config import apply_table_dialect_options


class TdxDaily(Base):
    """通达信板块行情"""

    __tablename__: str = "tdx_daily"
    __api_id__: ClassVar[int] = 378
    __api_name__: ClassVar[str] = "tdx_daily"
    __api_title__: ClassVar[str] = "通达信板块行情"
    __api_info_title__: ClassVar[str] = "通达信板块行情"
    __api_path__: ClassVar[List[str]] = ["数据接口", "股票数据", "打板专题数据"]
    __api_path_ids__: ClassVar[List[int]] = [1, 2, 10]
    __api_points_required__: ClassVar[int] = 0
    __api_special_permission__: ClassVar[bool] = False
    __has_vip__: ClassVar[bool] = False
    __dependencies__: ClassVar[List[str]] = ["trade_cal"]
    __primary_key__: ClassVar[List[str]] = ["ts_code", "trade_date"]
    __start_date__: ClassVar[str | None] = None
    __end_date__: ClassVar[str | None] = None
    __api_params__: ClassVar[Dict[str, Any]] = {
        "ts_code": {"type": "String", "required": False, "description": "板块代码"},
        "trade_date": {"type": "String", "required": False, "description": "交易日期"},
        "start_date": {"type": "String", "required": False, "description": "开始日期"},
        "end_date": {"type": "String", "required": False, "description": "结束日期"},
        "limit": {"type": "Int64", "required": False, "description": "单次返回数据长度"},
        "offset": {"type": "Int64", "required": False, "description": "请求数据的开始位移量"},
    }

    __mapper_args__ = {"primary_key": __primary_key__}
    __table_args__ = (
        PrimaryKeyConstraint(*__primary_key__),
        {
            "comment": "通达信板块行情",
            # MySQL引擎
            "mysql_engine": "InnoDB",
        },
    )

    ts_code = Column("ts_code", String(16), nullable=False, comment="板块代码")
    trade_date = Column("trade_date", Date, nullable=False, comment="交易日期")
    close = Column("close", Float, nullable=True, comment="收盘点位")
    open = Column("open", Float, nullable=True, comment="开盘点位")
    high = Column("high", Float, nullable=True, comment="最高点位")
    low = Column("low", Float, nullable=True, comment="最低点位")
    pre_close = Column("pre_close", Float, nullable=True, comment="昨日收盘点")
    change = Column("change", Float, nullable=True, comment="涨跌点位")
    pct_change = Column("pct_change", Float, nullable=True, comment="涨跌幅%")
    vol = Column("vol", Float, nullable=True, comment="成交量")
    amount = Column("amount", Float, nullable=True, comment="成交额, 对于期货指数，该字段存储持仓量")
    rise = Column("rise", String(), nullable=True, comment="收盘涨速%")
    vol_ratio = Column("vol_ratio", Float, nullable=True, comment="量比")
    turnover_rate = Column("turnover_rate", Float, nullable=True, comment="换手%")
    swing = Column("swing", Float, nullable=True, comment="振幅%")
    up_num = Column("up_num", Integer, nullable=True, comment="上涨家数")
    down_num = Column("down_num", Integer, nullable=True, comment="下跌家数")
    limit_up_num = Column("limit_up_num", Integer, nullable=True, comment="涨停家数")
    limit_down_num = Column("limit_down_num", Integer, nullable=True, comment="跌停家数")
    lu_days = Column("lu_days", Integer, nullable=True, comment="连涨天数")
    _3day = Column("3day", Float, nullable=True, comment="3日涨幅%")
    _5day = Column("5day", Float, nullable=True, comment="5日涨幅%")
    _10day = Column("10day", Float, nullable=True, comment="10日涨幅%")
    _20day = Column("20day", Float, nullable=True, comment="20日涨幅%")
    _60day = Column("60day", Float, nullable=True, comment="60日涨幅%")
    mtd = Column("mtd", Float, nullable=True, comment="月初至今%")
    ytd = Column("ytd", Float, nullable=True, comment="年初至今%")
    _1year = Column("1year", Float, nullable=True, comment="一年涨幅%")
    pe = Column("pe", String(), nullable=True, comment="市盈率")
    pb = Column("pb", String(), nullable=True, comment="市净率")
    float_mv = Column("float_mv", Float, nullable=True, comment="流通市值(亿)")
    ab_total_mv = Column("ab_total_mv", Float, nullable=True, comment="AB股总市值(亿)")
    float_share = Column("float_share", Float, nullable=True, comment="流通股(亿)")
    total_share = Column("total_share", Float, nullable=True, comment="总股本(亿)")
    bm_buy_net = Column("bm_buy_net", Float, nullable=True, comment="主买净额(元)")
    bm_buy_ratio = Column("bm_buy_ratio", Float, nullable=True, comment="主买占比%")
    bm_net = Column("bm_net", Float, nullable=True, comment="主力净额")
    bm_ratio = Column("bm_ratio", Float, nullable=True, comment="主力占比%")

apply_table_dialect_options(TdxDaily)
