# Generated by Django 3.1.4 on 2021-06-19 00:26

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


class Migration(migrations.Migration):

    dependencies = [
        ("stocks", "0016_auto_20210618_1701"),
    ]

    operations = [
        migrations.CreateModel(
            name="SimulatorGames",
            fields=[
                (
                    "game_id",
                    models.AutoField(primary_key=True, serialize=False, unique=True),
                ),
                ("date_created", models.DateField(auto_now_add=True)),
                ("date_ended", models.DateField()),
                ("game_name", models.CharField(max_length=100, unique=True)),
            ],
            options={
                "managed": True,
                "unique_together": {("game_id", "game_name")},
            },
        ),
        migrations.CreateModel(
            name="SimulatorPlayers",
            fields=[
                (
                    "simulator_player_id",
                    models.AutoField(primary_key=True, serialize=False, unique=True),
                ),
                ("liquid_cash", models.DecimalField(decimal_places=2, max_digits=10)),
                (
                    "simulator_game",
                    models.ForeignKey(
                        db_column="game_id",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="stocks.simulatorgames",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "managed": True,
                "unique_together": {("user", "simulator_game")},
            },
        ),
        migrations.AlterModelOptions(
            name="portfoliosectors",
            options={"managed": True},
        ),
        migrations.AlterField(
            model_name="portfoliosummary",
            name="symbol",
            field=models.ForeignKey(
                db_column="symbol",
                on_delete=django.db.models.deletion.CASCADE,
                to="stocks.listedequities",
            ),
        ),
        migrations.AlterField(
            model_name="portfoliotransactions",
            name="symbol",
            field=models.ForeignKey(
                db_column="symbol",
                on_delete=django.db.models.deletion.CASCADE,
                to="stocks.listedequities",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="portfoliosectors",
            unique_together={("user", "sector")},
        ),
        migrations.AlterModelTable(
            name="portfoliosectors",
            table="stocks_portfoliosectors",
        ),
        migrations.CreateModel(
            name="SimulatorTransactions",
            fields=[
                (
                    "simulator_transaction_id",
                    models.AutoField(primary_key=True, serialize=False, unique=True),
                ),
                ("date", models.DateField(verbose_name="Date")),
                ("bought_or_sold", models.CharField(max_length=10)),
                ("share_price", models.DecimalField(decimal_places=2, max_digits=12)),
                ("num_shares", models.IntegerField()),
                (
                    "simulator_player",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="stocks.simulatorplayers",
                    ),
                ),
                (
                    "symbol",
                    models.ForeignKey(
                        db_column="symbol",
                        default="AGL",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="stocks.listedequities",
                    ),
                ),
            ],
            options={
                "managed": True,
                "unique_together": {
                    (
                        "simulator_player_id",
                        "date",
                        "symbol",
                        "num_shares",
                        "bought_or_sold",
                    )
                },
            },
        ),
        migrations.CreateModel(
            name="SimulatorPortfolios",
            fields=[
                (
                    "simulator_portfolio_id",
                    models.AutoField(primary_key=True, serialize=False, unique=True),
                ),
                ("shares_remaining", models.IntegerField()),
                (
                    "average_cost",
                    models.DecimalField(decimal_places=2, max_digits=12, null=True),
                ),
                (
                    "book_cost",
                    models.DecimalField(decimal_places=2, max_digits=20, null=True),
                ),
                (
                    "current_market_price",
                    models.DecimalField(decimal_places=2, max_digits=12, null=True),
                ),
                (
                    "market_value",
                    models.DecimalField(decimal_places=2, max_digits=20, null=True),
                ),
                (
                    "total_gain_loss",
                    models.DecimalField(decimal_places=2, max_digits=20, null=True),
                ),
                (
                    "gain_loss_percent",
                    models.DecimalField(decimal_places=2, max_digits=6, null=True),
                ),
                (
                    "simulator_player_id",
                    models.ForeignKey(
                        db_column="simulator_player_id",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="stocks.simulatorplayers",
                    ),
                ),
                (
                    "symbol",
                    models.ForeignKey(
                        db_column="symbol",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="stocks.listedequities",
                    ),
                ),
            ],
            options={
                "managed": True,
                "unique_together": {("simulator_player_id", "symbol")},
            },
        ),
    ]
