# Generated by Django 5.2.9 on 2026-01-02 15:02

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("shared", "0002_alter_regimeeligibilityconfigmodel_id_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="FundTypePreferenceConfigModel",
            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",
                    ),
                ),
                ("fund_type", models.CharField(max_length=50, verbose_name="基金类型")),
                (
                    "style",
                    models.CharField(
                        blank=True,
                        help_text="如：成长、价值、平衡、商品等",
                        max_length=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_fund_type_preference",
                "indexes": [
                    models.Index(
                        fields=["regime", "is_active"], name="config_fund_regime_31442b_idx"
                    )
                ],
                "unique_together": {("regime", "fund_type", "style")},
            },
        ),
        migrations.CreateModel(
            name="HedgingInstrumentConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "instrument_code",
                    models.CharField(max_length=50, unique=True, verbose_name="工具代码"),
                ),
                ("instrument_name", models.CharField(max_length=100, verbose_name="工具名称")),
                (
                    "instrument_type",
                    models.CharField(
                        choices=[
                            ("futures", "期货"),
                            ("options", "期权"),
                            ("inverse_etf", "反向ETF"),
                            ("cash", "现金"),
                        ],
                        max_length=20,
                        verbose_name="工具类型",
                    ),
                ),
                (
                    "hedge_ratio",
                    models.FloatField(
                        default=1.0,
                        help_text="如 0.95 表示需要对冲95%的敞口",
                        verbose_name="对冲比例",
                    ),
                ),
                (
                    "underlying_index",
                    models.CharField(
                        blank=True,
                        help_text="如 000300.SH 表示沪深300",
                        max_length=50,
                        verbose_name="标的指数",
                    ),
                ),
                (
                    "cost_bps",
                    models.FloatField(
                        default=5.0, help_text="如 5 表示 0.05%", verbose_name="对冲成本（基点）"
                    ),
                ),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                ("notes", models.TextField(blank=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": "hedging_instrument_config",
                "indexes": [
                    models.Index(
                        fields=["instrument_type", "is_active"],
                        name="hedging_ins_instrum_f5ba64_idx",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="SectorPreferenceConfigModel",
            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",
                    ),
                ),
                ("sector_name", models.CharField(max_length=50, verbose_name="板块名称")),
                (
                    "weight",
                    models.FloatField(
                        default=0.5,
                        help_text="1.0 表示最强偏好，0.0 表示无偏好",
                        verbose_name="权重（0.0-1.0）",
                    ),
                ),
                ("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": "板块偏好配置",
                "verbose_name_plural": "板块偏好配置",
                "db_table": "config_sector_preference",
                "indexes": [
                    models.Index(
                        fields=["regime", "is_active"], name="config_sect_regime_2f148b_idx"
                    )
                ],
                "unique_together": {("regime", "sector_name")},
            },
        ),
        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"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="TransactionCostConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "market",
                    models.CharField(
                        choices=[
                            ("CN_A_SHARE", "A股"),
                            ("CN_HK_STOCK", "港股"),
                            ("US_STOCK", "美股"),
                            ("CN_FUND", "基金"),
                            ("CN_FUTURES", "期货"),
                            ("CRYPTO", "加密货币"),
                            ("other", "其他"),
                        ],
                        max_length=20,
                        verbose_name="市场",
                    ),
                ),
                (
                    "asset_class",
                    models.CharField(
                        choices=[
                            ("equity", "股票"),
                            ("fixed_income", "债券"),
                            ("fund", "基金"),
                            ("derivative", "衍生品"),
                            ("other", "其他"),
                        ],
                        max_length=20,
                        verbose_name="资产类别",
                    ),
                ),
                (
                    "commission_rate",
                    models.FloatField(
                        default=0.0003, help_text="如 0.0003 表示万分之三", verbose_name="佣金费率"
                    ),
                ),
                (
                    "slippage_rate",
                    models.FloatField(
                        default=0.0002, help_text="如 0.0002 表示万分之二", verbose_name="滑点费率"
                    ),
                ),
                (
                    "stamp_duty_rate",
                    models.FloatField(
                        default=0.001,
                        help_text="仅卖出时收取，如 0.001 表示千分之一",
                        verbose_name="印花税率",
                    ),
                ),
                (
                    "transfer_fee_rate",
                    models.FloatField(
                        default=1e-05, help_text="如 0.00001 表示万分之一", verbose_name="过户费率"
                    ),
                ),
                (
                    "min_commission",
                    models.DecimalField(
                        decimal_places=2,
                        default=5.0,
                        help_text="单笔交易最低佣金（元）",
                        max_digits=10,
                        verbose_name="最低佣金",
                    ),
                ),
                (
                    "cost_warning_threshold",
                    models.FloatField(
                        default=0.005,
                        help_text="成本占交易额比例超过此值时预警，如 0.005 表示 0.5%",
                        verbose_name="成本预警阈值",
                    ),
                ),
                ("is_active", models.BooleanField(default=True, verbose_name="是否启用")),
                ("notes", models.TextField(blank=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": "transaction_cost_config",
                "indexes": [
                    models.Index(
                        fields=["market", "asset_class"], name="transaction_market_ce8662_idx"
                    ),
                    models.Index(fields=["is_active"], name="transaction_is_acti_3d5550_idx"),
                ],
                "unique_together": {("market", "asset_class")},
            },
        ),
    ]
