# Generated by Django

from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ('simulated_trading', '0003_alter_simulatedaccountmodel_options_and_more'),
    ]

    operations = [
        # 添加证伪规则字段
        migrations.AddField(
            model_name='positionmodel',
            name='invalidation_rule_json',
            field=models.JSONField(
                blank=True,
                help_text='从信号继承的结构化证伪规则',
                null=True,
                verbose_name='证伪规则'
            ),
        ),
        migrations.AddField(
            model_name='positionmodel',
            name='invalidation_description',
            field=models.TextField(
                blank=True,
                help_text='人类可读的证伪条件描述',
                verbose_name='证伪描述'
            ),
        ),
        # 添加证伪状态字段
        migrations.AddField(
            model_name='positionmodel',
            name='is_invalidated',
            field=models.BooleanField(
                db_index=True,
                default=False,
                help_text='证伪条件已满足，建议平仓',
                verbose_name='是否已证伪'
            ),
        ),
        migrations.AddField(
            model_name='positionmodel',
            name='invalidation_reason',
            field=models.TextField(
                blank=True,
                help_text='证伪原因说明',
                verbose_name='证伪原因'
            ),
        ),
        migrations.AddField(
            model_name='positionmodel',
            name='invalidation_checked_at',
            field=models.DateTimeField(
                blank=True,
                help_text='最后一次检查证伪条件的时间',
                null=True,
                verbose_name='最后检查时间'
            ),
        ),
        # 添加索引
        migrations.AddIndex(
            model_name='positionmodel',
            index=models.Index(
                fields=['account', 'is_invalidated'],
                name='simulated_posi_account_id_idx'
            ),
        ),
        migrations.AddIndex(
            model_name='positionmodel',
            index=models.Index(
                fields=['is_invalidated', 'invalidation_checked_at'],
                name='simulated_posi_is_invalid_idx'
            ),
        ),
    ]
