# Generated by Django 5.2.9 on 2026-01-04 03:24

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("asset_analysis", "0002_assetanalysisalert_assetscoringlog"),
    ]

    operations = [
        migrations.CreateModel(
            name="AssetPoolConfig",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("name", models.CharField(max_length=100, unique=True, verbose_name="配置名称")),
                ("description", models.TextField(blank=True, null=True, verbose_name="配置描述")),
                (
                    "pool_type",
                    models.CharField(
                        choices=[
                            ("investable", "可投池"),
                            ("prohibited", "禁投池"),
                            ("watch", "观察池"),
                            ("candidate", "候选池"),
                        ],
                        max_length=20,
                        verbose_name="资产池类型",
                    ),
                ),
                (
                    "asset_category",
                    models.CharField(
                        choices=[
                            ("equity", "股票"),
                            ("fund", "基金"),
                            ("bond", "债券"),
                            ("wealth", "理财"),
                            ("commodity", "商品"),
                            ("index", "指数"),
                        ],
                        max_length=20,
                        verbose_name="资产类别",
                    ),
                ),
                ("min_total_score", models.FloatField(default=60.0, verbose_name="最低综合评分")),
                (
                    "min_regime_score",
                    models.FloatField(default=50.0, verbose_name="最低Regime评分"),
                ),
                (
                    "min_policy_score",
                    models.FloatField(default=50.0, verbose_name="最低Policy评分"),
                ),
                (
                    "max_total_score",
                    models.FloatField(default=30.0, verbose_name="最高综合评分（禁投）"),
                ),
                (
                    "max_regime_score",
                    models.FloatField(default=40.0, verbose_name="最高Regime评分（禁投）"),
                ),
                (
                    "max_policy_score",
                    models.FloatField(default=40.0, verbose_name="最高Policy评分（禁投）"),
                ),
                ("watch_min_score", models.FloatField(default=30.0, verbose_name="观察池最低分")),
                ("watch_max_score", models.FloatField(default=60.0, verbose_name="观察池最高分")),
                (
                    "max_volatility",
                    models.FloatField(blank=True, null=True, verbose_name="最大波动率"),
                ),
                ("max_drawdown", models.FloatField(blank=True, null=True, verbose_name="最大回撤")),
                (
                    "min_market_cap",
                    models.FloatField(blank=True, null=True, verbose_name="最小市值（元）"),
                ),
                ("max_pe_ratio", models.FloatField(blank=True, null=True, verbose_name="最大PE")),
                ("max_pb_ratio", models.FloatField(blank=True, null=True, verbose_name="最大PB")),
                ("is_active", models.BooleanField(default=True, 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_pool_config",
                "ordering": ["asset_category", "pool_type"],
                "indexes": [
                    models.Index(
                        fields=["asset_category", "pool_type"],
                        name="asset_pool__asset_c_0b85d7_idx",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="AssetPoolEntry",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "asset_category",
                    models.CharField(
                        choices=[
                            ("equity", "股票"),
                            ("fund", "基金"),
                            ("bond", "债券"),
                            ("wealth", "理财"),
                            ("commodity", "商品"),
                            ("index", "指数"),
                        ],
                        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="资产名称")),
                (
                    "pool_type",
                    models.CharField(
                        choices=[
                            ("investable", "可投池"),
                            ("prohibited", "禁投池"),
                            ("watch", "观察池"),
                            ("candidate", "候选池"),
                        ],
                        db_index=True,
                        max_length=20,
                        verbose_name="资产池类型",
                    ),
                ),
                ("total_score", models.FloatField(verbose_name="综合评分")),
                ("regime_score", models.FloatField(verbose_name="Regime评分")),
                ("policy_score", models.FloatField(verbose_name="Policy评分")),
                ("sentiment_score", models.FloatField(verbose_name="Sentiment评分")),
                ("signal_score", models.FloatField(verbose_name="Signal评分")),
                ("entry_date", models.DateField(db_index=True, verbose_name="入池日期")),
                (
                    "entry_reason",
                    models.CharField(blank=True, max_length=50, null=True, verbose_name="入池原因"),
                ),
                ("exit_date", models.DateField(blank=True, null=True, verbose_name="出池日期")),
                (
                    "exit_reason",
                    models.CharField(blank=True, max_length=50, null=True, verbose_name="出池原因"),
                ),
                (
                    "is_active",
                    models.BooleanField(db_index=True, default=True, verbose_name="是否活跃"),
                ),
                (
                    "risk_level",
                    models.CharField(default="未知", max_length=20, verbose_name="风险等级"),
                ),
                ("volatility", models.FloatField(blank=True, null=True, verbose_name="波动率")),
                ("max_drawdown", models.FloatField(blank=True, null=True, verbose_name="最大回撤")),
                (
                    "sector",
                    models.CharField(blank=True, max_length=50, null=True, verbose_name="行业"),
                ),
                ("market_cap", models.FloatField(blank=True, null=True, verbose_name="市值（元）")),
                ("pe_ratio", models.FloatField(blank=True, null=True, verbose_name="PE倍数")),
                ("pb_ratio", models.FloatField(blank=True, null=True, verbose_name="PB倍数")),
                ("context", models.JSONField(blank=True, default=dict, 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_pool_entry",
                "ordering": ["-entry_date", "-total_score"],
                "indexes": [
                    models.Index(fields=["-entry_date"], name="asset_pool__entry_d_630012_idx"),
                    models.Index(
                        fields=["pool_type", "is_active"], name="asset_pool__pool_ty_2ebe1a_idx"
                    ),
                    models.Index(fields=["asset_category"], name="asset_pool__asset_c_9872ed_idx"),
                    models.Index(fields=["total_score"], name="asset_pool__total_s_590bd4_idx"),
                ],
                "unique_together": {("asset_category", "asset_code", "pool_type", "entry_date")},
            },
        ),
    ]
