# Generated by Django 5.2.9 on 2026-01-03 16:16

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="WeightConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="如: default, policy_crisis, sentiment_extreme",
                        max_length=50,
                        unique=True,
                        verbose_name="配置名称",
                    ),
                ),
                ("description", models.TextField(blank=True, null=True, verbose_name="配置描述")),
                (
                    "regime_weight",
                    models.FloatField(
                        default=0.4,
                        validators=[
                            django.core.validators.MinValueValidator(0.0),
                            django.core.validators.MaxValueValidator(1.0),
                        ],
                        verbose_name="Regime 权重",
                    ),
                ),
                (
                    "policy_weight",
                    models.FloatField(
                        default=0.25,
                        validators=[
                            django.core.validators.MinValueValidator(0.0),
                            django.core.validators.MaxValueValidator(1.0),
                        ],
                        verbose_name="Policy 权重",
                    ),
                ),
                (
                    "sentiment_weight",
                    models.FloatField(
                        default=0.2,
                        validators=[
                            django.core.validators.MinValueValidator(0.0),
                            django.core.validators.MaxValueValidator(1.0),
                        ],
                        verbose_name="Sentiment 权重",
                    ),
                ),
                (
                    "signal_weight",
                    models.FloatField(
                        default=0.15,
                        validators=[
                            django.core.validators.MinValueValidator(0.0),
                            django.core.validators.MaxValueValidator(1.0),
                        ],
                        verbose_name="Signal 权重",
                    ),
                ),
                (
                    "asset_type",
                    models.CharField(
                        blank=True,
                        help_text="为空表示通用配置",
                        max_length=20,
                        null=True,
                        verbose_name="资产类型",
                    ),
                ),
                (
                    "market_condition",
                    models.CharField(
                        blank=True,
                        help_text="如: crisis, extreme_sentiment",
                        max_length=20,
                        null=True,
                        verbose_name="市场状态",
                    ),
                ),
                ("is_active", models.BooleanField(default=True, verbose_name="是否激活")),
                (
                    "priority",
                    models.IntegerField(
                        default=0, help_text="数字越大优先级越高", verbose_name="优先级"
                    ),
                ),
                ("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": "asset_weight_config",
                "ordering": ["-priority", "-created_at"],
            },
        ),
        migrations.CreateModel(
            name="AssetScoreCache",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "asset_type",
                    models.CharField(db_index=True, max_length=20, verbose_name="资产类型"),
                ),
                (
                    "asset_code",
                    models.CharField(db_index=True, max_length=20, verbose_name="资产代码"),
                ),
                ("asset_name", models.CharField(max_length=100, verbose_name="资产名称")),
                ("score_date", models.DateField(db_index=True, verbose_name="评分日期")),
                ("regime", models.CharField(max_length=20, verbose_name="Regime")),
                ("policy_level", models.CharField(max_length=2, verbose_name="政策档位")),
                ("sentiment_index", models.FloatField(verbose_name="情绪指数")),
                ("regime_score", models.FloatField(default=0.0, verbose_name="Regime 得分")),
                ("policy_score", models.FloatField(default=0.0, verbose_name="Policy 得分")),
                ("sentiment_score", models.FloatField(default=0.0, verbose_name="Sentiment 得分")),
                ("signal_score", models.FloatField(default=0.0, verbose_name="Signal 得分")),
                (
                    "total_score",
                    models.FloatField(db_index=True, default=0.0, verbose_name="综合得分"),
                ),
                ("rank", models.IntegerField(default=0, verbose_name="排名")),
                ("allocation_percent", models.FloatField(default=0.0, verbose_name="推荐比例(%)")),
                (
                    "risk_level",
                    models.CharField(default="未知", max_length=20, verbose_name="风险等级"),
                ),
                (
                    "custom_scores",
                    models.JSONField(blank=True, default=dict, verbose_name="自定义得分"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
            ],
            options={
                "verbose_name": "资产评分缓存",
                "verbose_name_plural": "资产评分缓存",
                "db_table": "asset_score_cache",
                "ordering": ["-score_date", "-total_score"],
                "indexes": [
                    models.Index(
                        fields=["score_date", "total_score"], name="asset_score_score_d_53bfe9_idx"
                    )
                ],
                "unique_together": {("asset_type", "asset_code", "score_date")},
            },
        ),
    ]
