# Generated by Django 5.2.10 on 2026-02-05 09:37

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("signal", "0006_alter_investmentsignalmodel_invalidation_logic_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="UnifiedSignalModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("signal_date", models.DateField(db_index=True, verbose_name="信号日期")),
                (
                    "signal_source",
                    models.CharField(
                        choices=[
                            ("regime", "宏观象限"),
                            ("factor", "因子选股"),
                            ("rotation", "资产轮动"),
                            ("hedge", "对冲组合"),
                            ("manual", "手动"),
                        ],
                        db_index=True,
                        max_length=20,
                        verbose_name="信号来源",
                    ),
                ),
                (
                    "signal_type",
                    models.CharField(
                        choices=[
                            ("buy", "买入"),
                            ("sell", "卖出"),
                            ("rebalance", "调仓"),
                            ("alert", "告警"),
                            ("info", "信息"),
                        ],
                        db_index=True,
                        max_length=20,
                        verbose_name="信号类型",
                    ),
                ),
                (
                    "asset_code",
                    models.CharField(
                        db_index=True,
                        help_text="如 ASSET_CODE、ETF_CODE 等",
                        max_length=20,
                        verbose_name="资产代码",
                    ),
                ),
                (
                    "asset_name",
                    models.CharField(blank=True, max_length=100, verbose_name="资产名称"),
                ),
                (
                    "target_weight",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="建议配置权重 (0-1)",
                        max_digits=5,
                        null=True,
                        verbose_name="目标权重",
                    ),
                ),
                (
                    "current_weight",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="当前配置权重",
                        max_digits=5,
                        null=True,
                        verbose_name="当前权重",
                    ),
                ),
                (
                    "priority",
                    models.IntegerField(
                        choices=[
                            (1, "最低"),
                            (2, "低"),
                            (3, "中低"),
                            (4, "中等"),
                            (5, "中高"),
                            (6, "高"),
                            (7, "很高"),
                            (8, "极高"),
                            (9, "紧急"),
                            (10, "最高"),
                        ],
                        default=5,
                        help_text="1-10，数字越大越重要",
                        verbose_name="优先级",
                    ),
                ),
                ("is_executed", models.BooleanField(default=False, verbose_name="是否已执行")),
                (
                    "executed_at",
                    models.DateTimeField(blank=True, null=True, verbose_name="执行时间"),
                ),
                (
                    "reason",
                    models.TextField(help_text="信号生成的详细原因", verbose_name="信号原因"),
                ),
                (
                    "action_required",
                    models.CharField(
                        blank=True,
                        help_text="建议采取的操作",
                        max_length=200,
                        verbose_name="所需操作",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="特定模块的额外信息",
                        verbose_name="额外数据",
                    ),
                ),
                (
                    "related_signal_id",
                    models.CharField(
                        blank=True,
                        help_text="原始模块中的信号ID",
                        max_length=100,
                        verbose_name="关联信号ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
            ],
            options={
                "verbose_name": "统一信号",
                "verbose_name_plural": "统一信号",
                "db_table": "unified_signal",
                "ordering": ["-signal_date", "-priority"],
                "indexes": [
                    models.Index(
                        fields=["signal_date", "-priority"], name="unified_sig_signal__8c5bd9_idx"
                    ),
                    models.Index(
                        fields=["signal_date", "signal_source"],
                        name="unified_sig_signal__a14f48_idx",
                    ),
                    models.Index(
                        fields=["asset_code", "signal_date"], name="unified_sig_asset_c_38ecdd_idx"
                    ),
                    models.Index(
                        fields=["is_executed", "signal_date"], name="unified_sig_is_exec_2f2317_idx"
                    ),
                ],
            },
        ),
    ]
