# 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 clickhouse_sqlalchemy import engines
from sqlalchemy import Column, PrimaryKeyConstraint, text

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


class ReportRc(Base):
    """券商盈利预测数据"""

    __tablename__: str = "report_rc"
    __api_id__: ClassVar[int] = 292
    __api_name__: ClassVar[str] = "report_rc"
    __api_title__: ClassVar[str] = "券商盈利预测数据"
    __api_info_title__: ClassVar[str] = "卖方盈利预测数据"
    __api_path__: ClassVar[List[str]] = ["数据接口", "股票数据", "特色数据", "券商盈利预测数据"]
    __api_path_ids__: ClassVar[List[int]] = [2, 14, 291, 292]
    __api_points_required__: ClassVar[int] = 2000
    __api_special_permission__: ClassVar[bool] = False
    __has_vip__: ClassVar[bool] = False
    __dependencies__: ClassVar[List[str]] = ["stock_basic"]
    __primary_key__: ClassVar[List[str]] = ["ts_code", "report_date"]
    __start_date__: ClassVar[str | None] = "2010-01-01"
    __end_date__: ClassVar[str | None] = None
    __api_params__: ClassVar[Dict[str, Any]] = {
        "ts_code": {"type": "str", "required": False, "description": "股票代码"},
        "report_date": {"type": "str", "required": False, "description": "报告日期"},
        "start_date": {"type": "str", "required": False, "description": "报告开始日期"},
        "end_date": {"type": "str", "required": False, "description": "报告结束日期"},
        "limit": {"type": "int", "required": False, "description": "单次返回数据长度"},
        "offset": {"type": "int", "required": False, "description": "请求数据的开始位移量"},
    }

    __mapper_args__ = {"primary_key": __primary_key__}
    __table_args__ = (
        PrimaryKeyConstraint(*__primary_key__),
        # ClickHouse引擎
        engines.ReplacingMergeTree(order_by=__primary_key__),
        {
            "comment": "券商盈利预测数据",
            # MySQL引擎
            "mysql_engine": "InnoDB",
            # StarRocks引擎
            "starrocks_primary_key": ",".join(__primary_key__),
            "starrocks_order_by": ",".join(__primary_key__),
            # Apache Doris引擎
            "doris_unique_key": __primary_key__,
            # Databend引擎
            "databend_cluster_by": __primary_key__,
        },
    )

    ts_code = Column("ts_code", String(16), nullable=False, default="", server_default=text("''"), comment="股票代码")
    name = Column("name", String(), nullable=False, default="", server_default=text("''"), comment="股票名称")
    report_date = Column(
        "report_date",
        Date,
        nullable=False,
        default="1970-01-01",
        server_default=text("'1970-01-01'"),
        comment="研报日期",
    )
    report_title = Column(
        "report_title", String(), nullable=False, default="", server_default=text("''"), comment="报告标题"
    )
    report_type = Column(
        "report_type", String(), nullable=False, default="", server_default=text("''"), comment="报告类型"
    )
    classify = Column("classify", String(), nullable=False, default="", server_default=text("''"), comment="报告分类")
    org_name = Column("org_name", String(), nullable=False, default="", server_default=text("''"), comment="机构名称")
    author_name = Column("author_name", String(), nullable=False, default="", server_default=text("''"), comment="作者")
    quarter = Column("quarter", String(), nullable=False, default="", server_default=text("''"), comment="预测报告期")
    op_rt = Column(
        "op_rt", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测营业收入(万元)"
    )
    op_pr = Column(
        "op_pr", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测营业利润(万元)"
    )
    tp = Column("tp", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测利润总额(万元)")
    np = Column("np", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测净利润(万元)")
    eps = Column("eps", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测每股收益(元)")
    pe = Column("pe", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测市盈率(元)")
    rd = Column("rd", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测股息率(元)")
    roe = Column(
        "roe", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测净资产收益率(元)"
    )
    ev_ebitda = Column(
        "ev_ebitda", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测EV/EBITDA"
    )
    rating = Column("rating", String(), nullable=False, default="", server_default=text("''"), comment="卖方评级")
    max_price = Column(
        "max_price", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测最高目标价"
    )
    min_price = Column(
        "min_price", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预测最低目标价"
    )
    imp_dg = Column("imp_dg", String(), nullable=False, default="", server_default=text("''"), comment="机构关注度")
    create_time = Column(
        "create_time",
        DateTime,
        nullable=False,
        default="1970-01-01 00:00:00",
        server_default=text("'1970-01-01 00:00:00'"),
        comment="TS数据更新时间",
    )
