# Generated by Django 5.2.10 on 2026-02-03 02:03

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("audit", "0002_attributionreport_experiencesummary_lossanalysis"),
    ]

    operations = [
        migrations.CreateModel(
            name="IndicatorThresholdConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "indicator_code",
                    models.CharField(max_length=50, unique=True, verbose_name="指标代码"),
                ),
                ("indicator_name", models.CharField(max_length=100, verbose_name="指标名称")),
                (
                    "level_low",
                    models.FloatField(
                        blank=True,
                        help_text="低水平阈值（如 PMI < 50 为收缩）",
                        null=True,
                        verbose_name="低水平阈值",
                    ),
                ),
                (
                    "level_high",
                    models.FloatField(
                        blank=True,
                        help_text="高水平阈值（如 PMI > 50 为扩张）",
                        null=True,
                        verbose_name="高水平阈值",
                    ),
                ),
                (
                    "base_weight",
                    models.FloatField(
                        default=1.0, help_text="指标的基础权重（0-1）", verbose_name="基础权重"
                    ),
                ),
                ("min_weight", models.FloatField(default=0.0, verbose_name="最小权重")),
                ("max_weight", models.FloatField(default=1.0, verbose_name="最大权重")),
                (
                    "decay_threshold",
                    models.FloatField(
                        default=0.2, help_text="F1 分数低于此值视为衰减", verbose_name="衰减阈值"
                    ),
                ),
                ("decay_penalty", models.FloatField(default=0.5, verbose_name="衰减惩罚系数")),
                ("improvement_threshold", models.FloatField(default=0.1, verbose_name="改进阈值")),
                ("improvement_bonus", models.FloatField(default=1.2, verbose_name="改进奖励系数")),
                (
                    "action_thresholds",
                    models.JSONField(
                        default=dict,
                        help_text='{"keep_min_f1": 0.6, "reduce_min_f1": 0.4, "remove_max_f1": 0.3}',
                        verbose_name="行为阈值配置",
                    ),
                ),
                (
                    "validation_periods",
                    models.JSONField(
                        default=list,
                        help_text='[{"name": "刚兑时期", "start": "2005-01-01", "end": "2017-12-31"}]',
                        verbose_name="分段验证配置",
                    ),
                ),
                (
                    "category",
                    models.CharField(
                        blank=True,
                        help_text="如 growth, inflation, sentiment",
                        max_length=50,
                        verbose_name="指标类别",
                    ),
                ),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                ("description", models.TextField(blank=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": "audit_indicator_threshold_config",
                "ordering": ["category", "indicator_code"],
            },
        ),
        migrations.CreateModel(
            name="ValidationSummaryModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "validation_run_id",
                    models.CharField(max_length=100, unique=True, verbose_name="验证运行ID"),
                ),
                ("run_date", models.DateTimeField(auto_now_add=True, verbose_name="运行日期")),
                ("evaluation_period_start", models.DateField(verbose_name="评估起始日期")),
                ("evaluation_period_end", models.DateField(verbose_name="评估结束日期")),
                ("total_indicators", models.IntegerField(default=0, verbose_name="总指标数")),
                ("approved_indicators", models.IntegerField(default=0, verbose_name="通过指标数")),
                ("rejected_indicators", models.IntegerField(default=0, verbose_name="拒绝指标数")),
                ("pending_indicators", models.IntegerField(default=0, verbose_name="待定指标数")),
                ("avg_f1_score", models.FloatField(null=True, verbose_name="平均F1分数")),
                (
                    "avg_stability_score",
                    models.FloatField(null=True, verbose_name="平均稳定性分数"),
                ),
                ("overall_recommendation", models.TextField(blank=True, verbose_name="总体建议")),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("pending", "待验证"),
                            ("in_progress", "验证中"),
                            ("completed", "已完成"),
                            ("failed", "失败"),
                        ],
                        default="pending",
                        max_length=20,
                        verbose_name="状态",
                    ),
                ),
                (
                    "is_shadow_mode",
                    models.BooleanField(default=False, verbose_name="是否为影子模式"),
                ),
                ("error_message", models.TextField(blank=True, verbose_name="错误信息")),
            ],
            options={
                "verbose_name": "验证摘要",
                "verbose_name_plural": "验证摘要",
                "db_table": "audit_validation_summary",
                "ordering": ["-run_date"],
            },
        ),
        migrations.CreateModel(
            name="IndicatorPerformanceModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "indicator_code",
                    models.CharField(db_index=True, max_length=50, verbose_name="指标代码"),
                ),
                ("evaluation_period_start", models.DateField(verbose_name="评估起始日期")),
                ("evaluation_period_end", models.DateField(verbose_name="评估结束日期")),
                ("true_positive_count", models.IntegerField(default=0, verbose_name="真阳性数")),
                ("false_positive_count", models.IntegerField(default=0, verbose_name="假阳性数")),
                ("true_negative_count", models.IntegerField(default=0, verbose_name="真阴性数")),
                ("false_negative_count", models.IntegerField(default=0, verbose_name="假阴性数")),
                ("precision", models.FloatField(null=True, verbose_name="精确率")),
                ("recall", models.FloatField(null=True, verbose_name="召回率")),
                ("f1_score", models.FloatField(null=True, verbose_name="F1 分数")),
                ("accuracy", models.FloatField(null=True, verbose_name="准确率")),
                ("lead_time_mean", models.FloatField(default=0.0, verbose_name="平均领先时间(月)")),
                ("lead_time_std", models.FloatField(default=0.0, verbose_name="领先时间标准差")),
                (
                    "pre_2015_correlation",
                    models.FloatField(null=True, verbose_name="2015年前相关性"),
                ),
                (
                    "post_2015_correlation",
                    models.FloatField(null=True, verbose_name="2015年后相关性"),
                ),
                ("stability_score", models.FloatField(default=0.0, verbose_name="稳定性分数")),
                ("decay_rate", models.FloatField(default=0.0, verbose_name="信号衰减率")),
                ("signal_strength", models.FloatField(default=0.0, verbose_name="信号强度")),
                (
                    "recommended_action",
                    models.CharField(max_length=20, null=True, verbose_name="建议操作"),
                ),
                ("recommended_weight", models.FloatField(default=0.0, verbose_name="建议权重")),
                ("confidence_level", models.FloatField(default=0.0, verbose_name="置信度")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "指标表现记录",
                "verbose_name_plural": "指标表现记录",
                "db_table": "audit_indicator_performance",
                "ordering": ["-evaluation_period_end", "-f1_score"],
                "indexes": [
                    models.Index(
                        fields=["indicator_code", "-evaluation_period_end"],
                        name="audit_indic_indicat_b5592a_idx",
                    )
                ],
            },
        ),
    ]
