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

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="SectorConstituentModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "sector_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="板块代码"),
                ),
                (
                    "stock_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="股票代码"),
                ),
                ("enter_date", models.DateField(verbose_name="纳入日期")),
                ("exit_date", models.DateField(blank=True, null=True, verbose_name="剔除日期")),
                ("is_current", models.BooleanField(default=True, verbose_name="是否当前成分股")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "板块成分股",
                "verbose_name_plural": "板块成分股",
                "db_table": "sector_constituent",
                "ordering": ["sector_code", "-enter_date"],
                "indexes": [
                    models.Index(
                        fields=["sector_code", "is_current"], name="sector_cons_sector__ec62a4_idx"
                    ),
                    models.Index(
                        fields=["stock_code", "is_current"], name="sector_cons_stock_c_c0d70d_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="SectorIndexModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "sector_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="板块代码"),
                ),
                ("trade_date", models.DateField(db_index=True, verbose_name="交易日期")),
                (
                    "open_price",
                    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="换手率（%）"),
                ),
                ("change_pct", models.FloatField(verbose_name="涨跌幅（%）")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "板块指数日线",
                "verbose_name_plural": "板块指数日线",
                "db_table": "sector_index_daily",
                "ordering": ["-trade_date"],
                "indexes": [
                    models.Index(
                        fields=["sector_code", "trade_date"], name="sector_inde_sector__516da0_idx"
                    ),
                    models.Index(fields=["trade_date"], name="sector_inde_trade_d_b61b2b_idx"),
                ],
                "unique_together": {("sector_code", "trade_date")},
            },
        ),
        migrations.CreateModel(
            name="SectorInfoModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "sector_code",
                    models.CharField(
                        db_index=True, max_length=10, unique=True, verbose_name="板块代码"
                    ),
                ),
                ("sector_name", models.CharField(max_length=50, verbose_name="板块名称")),
                (
                    "level",
                    models.CharField(
                        choices=[("SW1", "申万一级"), ("SW2", "申万二级"), ("SW3", "申万三级")],
                        db_index=True,
                        max_length=10,
                        verbose_name="板块级别",
                    ),
                ),
                (
                    "parent_code",
                    models.CharField(
                        blank=True, max_length=10, null=True, 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": "sector_info",
                "ordering": ["level", "sector_code"],
                "indexes": [
                    models.Index(fields=["sector_code"], name="sector_info_sector__1f0ee8_idx"),
                    models.Index(fields=["level"], name="sector_info_level_975789_idx"),
                    models.Index(fields=["parent_code"], name="sector_info_parent__8db958_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="SectorRelativeStrengthModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "sector_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="板块代码"),
                ),
                ("trade_date", models.DateField(db_index=True, verbose_name="交易日期")),
                (
                    "relative_strength",
                    models.FloatField(verbose_name="相对强弱（板块收益率 - 大盘收益率）"),
                ),
                ("momentum", models.FloatField(verbose_name="动量（N日累计收益率，%）")),
                ("momentum_window", models.IntegerField(default=20, verbose_name="动量计算窗口")),
                ("beta", models.FloatField(blank=True, null=True, verbose_name="贝塔系数")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "板块相对强弱",
                "verbose_name_plural": "板块相对强弱",
                "db_table": "sector_relative_strength",
                "ordering": ["-trade_date"],
                "indexes": [
                    models.Index(
                        fields=["sector_code", "-trade_date"], name="sector_rela_sector__e103bf_idx"
                    ),
                    models.Index(fields=["trade_date"], name="sector_rela_trade_d_1ef81e_idx"),
                ],
                "unique_together": {("sector_code", "trade_date")},
            },
        ),
    ]
