# Generated by Django 5.2.9 on 2026-01-02 15:03

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="FinancialDataModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "stock_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="股票代码"),
                ),
                ("report_date", models.DateField(db_index=True, verbose_name="报告期")),
                (
                    "report_type",
                    models.CharField(
                        choices=[
                            ("1Q", "一季报"),
                            ("2Q", "中报"),
                            ("3Q", "三季报"),
                            ("4Q", "年报"),
                        ],
                        max_length=10,
                        verbose_name="报告类型",
                    ),
                ),
                (
                    "revenue",
                    models.DecimalField(decimal_places=2, max_digits=20, verbose_name="营业收入"),
                ),
                (
                    "net_profit",
                    models.DecimalField(decimal_places=2, max_digits=20, verbose_name="净利润"),
                ),
                (
                    "revenue_growth",
                    models.FloatField(blank=True, null=True, verbose_name="营收增长率"),
                ),
                (
                    "net_profit_growth",
                    models.FloatField(blank=True, null=True, verbose_name="净利润增长率"),
                ),
                (
                    "total_assets",
                    models.DecimalField(decimal_places=2, max_digits=20, verbose_name="总资产"),
                ),
                (
                    "total_liabilities",
                    models.DecimalField(decimal_places=2, max_digits=20, verbose_name="总负债"),
                ),
                (
                    "equity",
                    models.DecimalField(decimal_places=2, max_digits=20, verbose_name="股东权益"),
                ),
                ("roe", models.FloatField(verbose_name="净资产收益率")),
                ("roa", models.FloatField(blank=True, null=True, verbose_name="总资产收益率")),
                ("debt_ratio", models.FloatField(verbose_name="资产负债率")),
                ("publish_date", models.DateField(blank=True, null=True, verbose_name="发布日期")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "财务数据",
                "verbose_name_plural": "财务数据",
                "db_table": "equity_financial_data",
                "ordering": ["-report_date"],
                "indexes": [
                    models.Index(
                        fields=["stock_code", "report_date"], name="equity_fina_stock_c_b92cbb_idx"
                    ),
                    models.Index(fields=["report_date"], name="equity_fina_report__2a9fde_idx"),
                ],
                "unique_together": {("stock_code", "report_date", "report_type")},
            },
        ),
        migrations.CreateModel(
            name="StockDailyModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "stock_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="股票代码"),
                ),
                ("trade_date", models.DateField(db_index=True, verbose_name="交易日期")),
                (
                    "open",
                    models.DecimalField(decimal_places=2, max_digits=10, verbose_name="开盘价"),
                ),
                (
                    "high",
                    models.DecimalField(decimal_places=2, max_digits=10, verbose_name="最高价"),
                ),
                (
                    "low",
                    models.DecimalField(decimal_places=2, max_digits=10, verbose_name="最低价"),
                ),
                (
                    "close",
                    models.DecimalField(decimal_places=2, max_digits=10, verbose_name="收盘价"),
                ),
                ("volume", models.BigIntegerField(verbose_name="成交量（手）")),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2, max_digits=20, verbose_name="成交额（元）"
                    ),
                ),
                (
                    "turnover_rate",
                    models.FloatField(blank=True, null=True, verbose_name="换手率（%）"),
                ),
                ("adj_factor", models.FloatField(default=1.0, verbose_name="复权因子")),
                (
                    "ma5",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        max_digits=10,
                        null=True,
                        verbose_name="5日均线",
                    ),
                ),
                (
                    "ma20",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        max_digits=10,
                        null=True,
                        verbose_name="20日均线",
                    ),
                ),
                (
                    "ma60",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        max_digits=10,
                        null=True,
                        verbose_name="60日均线",
                    ),
                ),
                ("macd", models.FloatField(blank=True, null=True, verbose_name="MACD")),
                (
                    "macd_signal",
                    models.FloatField(blank=True, null=True, verbose_name="MACD 信号线"),
                ),
                ("macd_hist", models.FloatField(blank=True, null=True, verbose_name="MACD 柱状图")),
                ("rsi", models.FloatField(blank=True, null=True, verbose_name="RSI（14日）")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "个股日线数据",
                "verbose_name_plural": "个股日线数据",
                "db_table": "equity_stock_daily",
                "ordering": ["-trade_date"],
                "indexes": [
                    models.Index(
                        fields=["stock_code", "trade_date"], name="equity_stoc_stock_c_a5f66d_idx"
                    ),
                    models.Index(fields=["trade_date"], name="equity_stoc_trade_d_c37cb5_idx"),
                ],
                "unique_together": {("stock_code", "trade_date")},
            },
        ),
        migrations.CreateModel(
            name="StockInfoModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "stock_code",
                    models.CharField(
                        db_index=True, max_length=10, unique=True, verbose_name="股票代码"
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="股票名称")),
                ("sector", models.CharField(max_length=50, verbose_name="所属行业")),
                (
                    "market",
                    models.CharField(
                        choices=[("SH", "上交所"), ("SZ", "深交所"), ("BJ", "北交所")],
                        max_length=10,
                        verbose_name="交易市场",
                    ),
                ),
                ("list_date", models.DateField(verbose_name="上市日期")),
                ("is_active", models.BooleanField(default=True, verbose_name="是否活跃")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "个股基本信息",
                "verbose_name_plural": "个股基本信息",
                "db_table": "equity_stock_info",
                "indexes": [
                    models.Index(fields=["stock_code"], name="equity_stoc_stock_c_f946d8_idx"),
                    models.Index(fields=["sector"], name="equity_stoc_sector_567ccf_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="ValuationModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "stock_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="股票代码"),
                ),
                ("trade_date", models.DateField(db_index=True, verbose_name="交易日期")),
                ("pe", models.FloatField(blank=True, null=True, verbose_name="市盈率（动态）")),
                ("pe_ttm", models.FloatField(blank=True, null=True, verbose_name="市盈率（TTM）")),
                ("pb", models.FloatField(blank=True, null=True, verbose_name="市净率")),
                ("ps", models.FloatField(blank=True, null=True, verbose_name="市销率")),
                (
                    "total_mv",
                    models.DecimalField(
                        decimal_places=2, max_digits=20, verbose_name="总市值（元）"
                    ),
                ),
                (
                    "circ_mv",
                    models.DecimalField(
                        decimal_places=2, max_digits=20, verbose_name="流通市值（元）"
                    ),
                ),
                (
                    "dividend_yield",
                    models.FloatField(blank=True, null=True, verbose_name="股息率（%）"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "估值指标",
                "verbose_name_plural": "估值指标",
                "db_table": "equity_valuation",
                "ordering": ["-trade_date"],
                "indexes": [
                    models.Index(
                        fields=["stock_code", "trade_date"], name="equity_valu_stock_c_6106dc_idx"
                    ),
                    models.Index(fields=["trade_date"], name="equity_valu_trade_d_09f396_idx"),
                ],
                "unique_together": {("stock_code", "trade_date")},
            },
        ),
    ]
