# Generated by Django 5.2.10 on 2026-03-23 23:36

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="PulseIndicatorConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "indicator_code",
                    models.CharField(
                        help_text="对应 macro 模块的指标代码，如 CN_TERM_SPREAD_10Y2Y",
                        max_length=50,
                        unique=True,
                        verbose_name="指标代码",
                    ),
                ),
                ("indicator_name", models.CharField(max_length=100, verbose_name="指标名称")),
                (
                    "dimension",
                    models.CharField(
                        choices=[
                            ("growth", "增长"),
                            ("inflation", "通胀"),
                            ("liquidity", "流动性"),
                            ("sentiment", "情绪"),
                        ],
                        max_length=20,
                        verbose_name="所属维度",
                    ),
                ),
                (
                    "frequency",
                    models.CharField(
                        choices=[("daily", "日频"), ("weekly", "周频"), ("monthly", "月频")],
                        default="daily",
                        max_length=20,
                        verbose_name="数据频率",
                    ),
                ),
                (
                    "weight",
                    models.FloatField(
                        default=1.0,
                        help_text="维度内各指标的权重，默认等权=1.0",
                        verbose_name="维度内权重",
                    ),
                ),
                (
                    "signal_type",
                    models.CharField(
                        choices=[
                            ("zscore", "Z-Score"),
                            ("level", "绝对水平"),
                            ("pct_change", "涨跌幅"),
                        ],
                        default="zscore",
                        max_length=20,
                        verbose_name="信号类型",
                    ),
                ),
                (
                    "bullish_threshold",
                    models.FloatField(
                        default=1.0,
                        help_text="超过此阈值判定为 bullish",
                        verbose_name="Bullish 阈值",
                    ),
                ),
                (
                    "bearish_threshold",
                    models.FloatField(
                        default=-1.0,
                        help_text="低于此阈值判定为 bearish",
                        verbose_name="Bearish 阈值",
                    ),
                ),
                (
                    "neutral_band",
                    models.FloatField(
                        default=0.5,
                        help_text="|value| < neutral_band 时判定为 neutral",
                        verbose_name="中性区间",
                    ),
                ),
                (
                    "signal_multiplier",
                    models.FloatField(
                        default=0.4,
                        help_text="z_score → signal_score 的乘数。负值表示逆向指标。",
                        verbose_name="信号乘数",
                    ),
                ),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                ("description", models.TextField(blank=True, default="", verbose_name="说明")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Pulse 指标配置",
                "verbose_name_plural": "Pulse 指标配置",
                "db_table": "pulse_indicator_config",
                "ordering": ["dimension", "indicator_code"],
            },
        ),
        migrations.CreateModel(
            name="PulseLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("observed_at", models.DateField(db_index=True, verbose_name="观测日期")),
                ("regime_context", models.CharField(max_length=20, verbose_name="当时的 Regime")),
                ("growth_score", models.FloatField(default=0.0, verbose_name="增长脉搏")),
                ("inflation_score", models.FloatField(default=0.0, verbose_name="通胀脉搏")),
                ("liquidity_score", models.FloatField(default=0.0, verbose_name="流动性脉搏")),
                ("sentiment_score", models.FloatField(default=0.0, verbose_name="情绪脉搏")),
                ("composite_score", models.FloatField(verbose_name="综合分数")),
                ("regime_strength", models.CharField(max_length=20, verbose_name="Regime 内强弱")),
                ("transition_warning", models.BooleanField(default=False, verbose_name="转折预警")),
                (
                    "transition_direction",
                    models.CharField(blank=True, max_length=20, null=True, verbose_name="预警方向"),
                ),
                ("indicator_readings", models.JSONField(default=dict, verbose_name="指标明细")),
                ("transition_reasons", models.JSONField(default=list, verbose_name="预警原因")),
                ("data_source", models.CharField(default="calculated", max_length=20)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "db_table": "pulse_log",
                "ordering": ["-observed_at"],
                "get_latest_by": "observed_at",
            },
        ),
        migrations.CreateModel(
            name="NavigatorAssetConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "regime_name",
                    models.CharField(
                        choices=[
                            ("Recovery", "复苏"),
                            ("Overheat", "过热"),
                            ("Stagflation", "滞胀"),
                            ("Deflation", "通缩"),
                        ],
                        max_length=20,
                        verbose_name="Regime 名称",
                    ),
                ),
                (
                    "asset_weight_ranges",
                    models.JSONField(
                        help_text='格式: {"equity": [0.5, 0.7], "bond": [0.15, 0.3], "commodity": [0.05, 0.15], "cash": [0.05, 0.15]}',
                        verbose_name="资产权重区间",
                    ),
                ),
                (
                    "risk_budget",
                    models.FloatField(
                        default=0.7, help_text="0-1 之间的值", verbose_name="风险预算(仓位上限)"
                    ),
                ),
                (
                    "recommended_sectors",
                    models.JSONField(
                        default=list,
                        help_text='格式: ["消费", "科技", "金融"]',
                        verbose_name="推荐板块",
                    ),
                ),
                (
                    "benefiting_styles",
                    models.JSONField(
                        default=list, help_text='格式: ["成长", "中小盘"]', 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": "Navigator 资产配置",
                "verbose_name_plural": "Navigator 资产配置",
                "db_table": "navigator_asset_config",
                "ordering": ["regime_name"],
                "unique_together": {("regime_name", "is_active")},
            },
        ),
    ]
