# Generated by Django 5.2.12 on 2026-04-26 23:34

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("equity", "0007_add_valuation_repair_config"),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(
            database_operations=[],
            state_operations=[
        migrations.CreateModel(
            name="StockScreeningRuleConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "regime",
                    models.CharField(
                        db_index=True,
                        help_text="Recovery/Overheat/Stagflation/Deflation",
                        max_length=20,
                        verbose_name="Regime",
                    ),
                ),
                ("rule_name", models.CharField(max_length=100, verbose_name="规则名称")),
                ("min_roe", models.FloatField(default=0.0, verbose_name="最低 ROE（%）")),
                (
                    "min_revenue_growth",
                    models.FloatField(default=0.0, verbose_name="最低营收增长率（%）"),
                ),
                (
                    "min_profit_growth",
                    models.FloatField(default=0.0, verbose_name="最低净利润增长率（%）"),
                ),
                (
                    "max_debt_ratio",
                    models.FloatField(default=100.0, verbose_name="最高资产负债率（%）"),
                ),
                ("max_pe", models.FloatField(default=999.0, verbose_name="最高 PE")),
                ("max_pb", models.FloatField(default=999.0, verbose_name="最高 PB")),
                (
                    "min_market_cap",
                    models.DecimalField(
                        decimal_places=2, default=0, max_digits=20, verbose_name="最低市值（元）"
                    ),
                ),
                (
                    "sector_preference",
                    models.JSONField(blank=True, default=list, verbose_name="偏好行业列表"),
                ),
                ("max_count", models.IntegerField(default=50, verbose_name="最多返回个股数量")),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                (
                    "priority",
                    models.IntegerField(default=0, 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": "config_stock_screening_rule",
                "ordering": ["-priority", "-created_at"],
                "indexes": [
                    models.Index(
                        fields=["regime", "is_active"], name="config_stoc_regime_75d824_idx"
                    ),
                    models.Index(
                        fields=["regime", "priority"], name="config_stoc_regime_3c8c15_idx"
                    ),
                ],
            },
        ),
            ],
        ),
    ]
