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

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="FundHoldingModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "fund_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="基金代码"),
                ),
                ("report_date", models.DateField(db_index=True, verbose_name="报告期")),
                (
                    "stock_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="股票代码"),
                ),
                ("stock_name", models.CharField(max_length=100, verbose_name="股票名称")),
                (
                    "holding_amount",
                    models.BigIntegerField(blank=True, null=True, verbose_name="持有数量（股）"),
                ),
                (
                    "holding_value",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        max_digits=20,
                        null=True,
                        verbose_name="持有市值（元）",
                    ),
                ),
                (
                    "holding_ratio",
                    models.FloatField(blank=True, null=True, verbose_name="占净值比例（%）"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "基金持仓",
                "verbose_name_plural": "基金持仓",
                "db_table": "fund_holding",
                "ordering": ["-report_date", "-holding_ratio"],
                "indexes": [
                    models.Index(
                        fields=["fund_code", "-report_date"], name="fund_holdin_fund_co_7ecb67_idx"
                    ),
                    models.Index(
                        fields=["stock_code", "-report_date"], name="fund_holdin_stock_c_42227e_idx"
                    ),
                ],
                "unique_together": {("fund_code", "report_date", "stock_code")},
            },
        ),
        migrations.CreateModel(
            name="FundInfoModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "fund_code",
                    models.CharField(
                        db_index=True, max_length=10, unique=True, verbose_name="基金代码"
                    ),
                ),
                ("fund_name", models.CharField(max_length=100, verbose_name="基金名称")),
                (
                    "fund_type",
                    models.CharField(
                        db_index=True,
                        help_text="股票型/债券型/混合型/指数型/货币型/QDII/商品型",
                        max_length=20,
                        verbose_name="基金类型",
                    ),
                ),
                (
                    "investment_style",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text="成长/价值/平衡/商品/稳健",
                        max_length=20,
                        null=True,
                        verbose_name="投资风格",
                    ),
                ),
                ("setup_date", models.DateField(blank=True, null=True, verbose_name="成立日期")),
                (
                    "management_company",
                    models.CharField(blank=True, max_length=100, null=True, verbose_name="管理人"),
                ),
                (
                    "custodian",
                    models.CharField(blank=True, max_length=100, null=True, verbose_name="托管人"),
                ),
                (
                    "fund_scale",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        max_digits=20,
                        null=True,
                        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": "基金基本信息",
                "verbose_name_plural": "基金基本信息",
                "db_table": "fund_info",
                "ordering": ["fund_code"],
                "indexes": [
                    models.Index(fields=["fund_code"], name="fund_info_fund_co_a515c3_idx"),
                    models.Index(
                        fields=["fund_type", "is_active"], name="fund_info_fund_ty_24b931_idx"
                    ),
                    models.Index(fields=["investment_style"], name="fund_info_investm_79f379_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="FundManagerModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "fund_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="基金代码"),
                ),
                ("manager_name", models.CharField(max_length=50, verbose_name="经理姓名")),
                ("tenure_start", models.DateField(verbose_name="任职开始日期")),
                (
                    "tenure_end",
                    models.DateField(blank=True, null=True, verbose_name="任职结束日期"),
                ),
                (
                    "total_tenure_days",
                    models.IntegerField(blank=True, null=True, verbose_name="任期天数"),
                ),
                (
                    "fund_return",
                    models.FloatField(
                        blank=True, null=True, verbose_name="任期期间基金收益率（%）"
                    ),
                ),
                ("is_current", models.BooleanField(default=True, verbose_name="是否在任")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "基金经理",
                "verbose_name_plural": "基金经理",
                "db_table": "fund_manager",
                "ordering": ["fund_code", "-tenure_start"],
                "indexes": [
                    models.Index(
                        fields=["fund_code", "is_current"], name="fund_manage_fund_co_1268c1_idx"
                    ),
                    models.Index(fields=["manager_name"], name="fund_manage_manager_6e7d74_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="FundNetValueModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "fund_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="基金代码"),
                ),
                ("nav_date", models.DateField(db_index=True, verbose_name="净值日期")),
                (
                    "unit_nav",
                    models.DecimalField(decimal_places=4, max_digits=10, verbose_name="单位净值"),
                ),
                (
                    "accum_nav",
                    models.DecimalField(decimal_places=4, max_digits=10, verbose_name="累计净值"),
                ),
                (
                    "daily_return",
                    models.FloatField(blank=True, null=True, verbose_name="日收益率（%）"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "基金净值",
                "verbose_name_plural": "基金净值",
                "db_table": "fund_net_value",
                "ordering": ["-nav_date"],
                "indexes": [
                    models.Index(
                        fields=["fund_code", "-nav_date"], name="fund_net_va_fund_co_2355e6_idx"
                    ),
                    models.Index(fields=["nav_date"], name="fund_net_va_nav_dat_774dd0_idx"),
                ],
                "unique_together": {("fund_code", "nav_date")},
            },
        ),
        migrations.CreateModel(
            name="FundPerformanceModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "fund_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="基金代码"),
                ),
                ("start_date", models.DateField(verbose_name="计算起始日期")),
                ("end_date", models.DateField(db_index=True, verbose_name="计算结束日期")),
                ("total_return", models.FloatField(verbose_name="区间收益率（%）")),
                (
                    "annualized_return",
                    models.FloatField(blank=True, null=True, verbose_name="年化收益率（%）"),
                ),
                (
                    "volatility",
                    models.FloatField(blank=True, null=True, verbose_name="波动率（%）"),
                ),
                (
                    "max_drawdown",
                    models.FloatField(blank=True, null=True, verbose_name="最大回撤（%）"),
                ),
                ("sharpe_ratio", models.FloatField(blank=True, null=True, verbose_name="夏普比率")),
                ("beta", models.FloatField(blank=True, null=True, verbose_name="贝塔系数")),
                ("alpha", models.FloatField(blank=True, null=True, verbose_name="阿尔法（%）")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "基金业绩指标",
                "verbose_name_plural": "基金业绩指标",
                "db_table": "fund_performance",
                "ordering": ["-end_date"],
                "indexes": [
                    models.Index(
                        fields=["fund_code", "-end_date"], name="fund_perfor_fund_co_9b479e_idx"
                    ),
                    models.Index(fields=["end_date"], name="fund_perfor_end_dat_f6a761_idx"),
                ],
                "unique_together": {("fund_code", "start_date", "end_date")},
            },
        ),
        migrations.CreateModel(
            name="FundSectorAllocationModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "fund_code",
                    models.CharField(db_index=True, max_length=10, verbose_name="基金代码"),
                ),
                ("report_date", models.DateField(db_index=True, verbose_name="报告期")),
                ("sector_name", models.CharField(max_length=50, verbose_name="行业名称")),
                ("allocation_ratio", models.FloatField(verbose_name="配置比例（%）")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "verbose_name": "基金行业配置",
                "verbose_name_plural": "基金行业配置",
                "db_table": "fund_sector_allocation",
                "ordering": ["-report_date", "-allocation_ratio"],
                "indexes": [
                    models.Index(
                        fields=["fund_code", "-report_date"], name="fund_sector_fund_co_08f05a_idx"
                    ),
                    models.Index(fields=["report_date"], name="fund_sector_report__a86144_idx"),
                ],
                "unique_together": {("fund_code", "report_date", "sector_name")},
            },
        ),
    ]
