# Generated by Django 5.0.6 on 2024-06-21 12:42

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("io", "0007_alter_exportsource_query_params"),
        ("wbfdm", "0019_alter_controversy_source"),
    ]

    operations = [
        migrations.CreateModel(
            name="OptionAggregate",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("type", models.CharField(choices=[("PUT", "Put"), ("CALL", "Call")], max_length=6)),
                ("date", models.DateField()),
                ("volume", models.FloatField(blank=True, help_text="Option Volume", null=True, verbose_name="Volume")),
                (
                    "volume_5d",
                    models.FloatField(blank=True, help_text="Option Volume (5D)", null=True, verbose_name="Volume 5D"),
                ),
                (
                    "volume_20d",
                    models.FloatField(
                        blank=True, help_text="Option Volume (20D)", null=True, verbose_name="Volume 20D"
                    ),
                ),
                (
                    "volume_50d",
                    models.FloatField(
                        blank=True, help_text="Option Volume (50D)", null=True, verbose_name="Volume 50D"
                    ),
                ),
                (
                    "open_interest",
                    models.FloatField(blank=True, help_text="Open Interest", null=True, verbose_name="Open Interest"),
                ),
                ("volatility_30d", models.FloatField(blank=True, null=True, verbose_name="Volatility (30D)")),
                ("volatility_60d", models.FloatField(blank=True, null=True, verbose_name="Volatility (60D)")),
                ("volatility_90d", models.FloatField(blank=True, null=True, verbose_name="Volatility (90D)")),
                (
                    "import_source",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="io.importsource"
                    ),
                ),
                (
                    "instrument",
                    models.ForeignKey(
                        limit_choices_to=models.Q(("children__isnull", True)),
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="%(class)s",
                        to="wbfdm.instrument",
                        verbose_name="Instrument",
                    ),
                ),
            ],
            options={
                "verbose_name": "Option Aggregate",
                "verbose_name_plural": "Options Aggregates",
            },
        ),
        migrations.CreateModel(
            name="Option",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("type", models.CharField(choices=[("PUT", "Put"), ("CALL", "Call")], max_length=6)),
                ("date", models.DateField()),
                ("volume", models.FloatField(blank=True, help_text="Option Volume", null=True, verbose_name="Volume")),
                (
                    "volume_5d",
                    models.FloatField(blank=True, help_text="Option Volume (5D)", null=True, verbose_name="Volume 5D"),
                ),
                (
                    "volume_20d",
                    models.FloatField(
                        blank=True, help_text="Option Volume (20D)", null=True, verbose_name="Volume 20D"
                    ),
                ),
                (
                    "volume_50d",
                    models.FloatField(
                        blank=True, help_text="Option Volume (50D)", null=True, verbose_name="Volume 50D"
                    ),
                ),
                (
                    "open_interest",
                    models.FloatField(blank=True, help_text="Open Interest", null=True, verbose_name="Open Interest"),
                ),
                ("volatility_30d", models.FloatField(blank=True, null=True, verbose_name="Volatility (30D)")),
                ("volatility_60d", models.FloatField(blank=True, null=True, verbose_name="Volatility (60D)")),
                ("volatility_90d", models.FloatField(blank=True, null=True, verbose_name="Volatility (90D)")),
                ("contract_identifier", models.CharField(max_length=255, verbose_name="Contract Name")),
                ("strike", models.FloatField(verbose_name="Strike")),
                ("expiration_date", models.DateField(verbose_name="Expiration Date")),
                ("open", models.FloatField(blank=True, null=True, verbose_name="Open")),
                ("high", models.FloatField(blank=True, null=True, verbose_name="High")),
                ("low", models.FloatField(blank=True, null=True, verbose_name="Low")),
                ("close", models.FloatField(blank=True, null=True, verbose_name="Close")),
                ("bid", models.FloatField(blank=True, null=True, verbose_name="Bid")),
                ("ask", models.FloatField(blank=True, null=True, verbose_name="Ask")),
                (
                    "vwap",
                    models.FloatField(blank=True, help_text="Open Interest", null=True, verbose_name="Open Interest"),
                ),
                (
                    "risk_delta",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Delta"', null=True, verbose_name="Delta"
                    ),
                ),
                (
                    "risk_theta",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Theta"', null=True, verbose_name="Theta"
                    ),
                ),
                (
                    "risk_gamma",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Gamma"', null=True, verbose_name="Gamma"
                    ),
                ),
                (
                    "risk_vega",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Vega"', null=True, verbose_name="Vega"
                    ),
                ),
                (
                    "risk_rho",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Rho"', null=True, verbose_name="Rho"
                    ),
                ),
                (
                    "risk_lambda",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Lambda"', null=True, verbose_name="Lambda"
                    ),
                ),
                (
                    "risk_epsilon",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Epsilon"', null=True, verbose_name="Epsilon"
                    ),
                ),
                (
                    "risk_vomma",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Vomma"', null=True, verbose_name="Vomma"
                    ),
                ),
                (
                    "risk_vera",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Vera"', null=True, verbose_name="Vera"
                    ),
                ),
                (
                    "risk_speed",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Speed"', null=True, verbose_name="Speed"
                    ),
                ),
                (
                    "risk_zomma",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Zomma"', null=True, verbose_name="Zomma"
                    ),
                ),
                (
                    "risk_color",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Color"', null=True, verbose_name="Color"
                    ),
                ),
                (
                    "risk_ultima",
                    models.FloatField(
                        blank=True, help_text='Option risk metrics "Ultima"', null=True, verbose_name="Ultima"
                    ),
                ),
                (
                    "import_source",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="io.importsource"
                    ),
                ),
                (
                    "instrument",
                    models.ForeignKey(
                        limit_choices_to=models.Q(("children__isnull", True)),
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="%(class)s",
                        to="wbfdm.instrument",
                        verbose_name="Instrument",
                    ),
                ),
            ],
            options={
                "verbose_name": "Option",
                "verbose_name_plural": "Options",
                "indexes": [
                    models.Index(fields=["instrument", "date", "type"], name="wbfdm_optio_instrum_aeea29_idx"),
                    models.Index(fields=["instrument", "date"], name="wbfdm_optio_instrum_1529cf_idx"),
                    models.Index(fields=["type"], name="wbfdm_optio_type_948af8_idx"),
                ],
            },
        ),
        migrations.AddConstraint(
            model_name="option",
            constraint=models.CheckConstraint(
                check=models.Q(("date__week_day__in", [1, 7]), _negated=True), name="wbfdm_option_weekday_constraint"
            ),
        ),
        migrations.AddConstraint(
            model_name="option",
            constraint=models.UniqueConstraint(
                fields=("instrument", "contract_identifier", "date", "type"), name="unique_option"
            ),
        ),
        migrations.AddIndex(
            model_name="optionaggregate",
            index=models.Index(fields=["instrument", "date", "type"], name="wbfdm_optio_instrum_df2778_idx"),
        ),
        migrations.AddIndex(
            model_name="optionaggregate",
            index=models.Index(fields=["instrument", "date"], name="wbfdm_optio_instrum_6ca630_idx"),
        ),
        migrations.AddIndex(
            model_name="optionaggregate",
            index=models.Index(fields=["type"], name="wbfdm_optio_type_4d93d5_idx"),
        ),
        migrations.AddConstraint(
            model_name="optionaggregate",
            constraint=models.CheckConstraint(
                check=models.Q(("date__week_day__in", [1, 7]), _negated=True),
                name="wbfdm_optionaggregate_weekday_constraint",
            ),
        ),
        migrations.AddConstraint(
            model_name="optionaggregate",
            constraint=models.UniqueConstraint(fields=("instrument", "date", "type"), name="unique_option_aggregate"),
        ),
    ]
