# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-15 02:39
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import strategy_ledger.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='OptionPosition',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('option_symbol', models.CharField(max_length=20)),
                ('strike', models.PositiveIntegerField()),
                ('expiry_date', models.DateField()),
                ('entry_date', models.DateField(default=django.utils.timezone.now)),
                ('entry_price', models.PositiveIntegerField()),
                ('exit_price', models.IntegerField()),
                ('exit_date', models.DateField()),
                ('contracts', models.IntegerField()),
                ('position_type', models.IntegerField(choices=[(1, 'Call'), (2, 'Put')], default=1)),
                ('note', models.TextField(blank=True, null=True)),
                ('rolled_to', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rolled_from', to='strategy_ledger.OptionPosition')),
            ],
        ),
        migrations.CreateModel(
            name='SecurityPosition',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ticker', models.CharField(max_length=5)),
                ('shares', models.IntegerField()),
                ('purchase_date', models.DateField(default=django.utils.timezone.now)),
                ('purchase_price', models.PositiveIntegerField()),
                ('sell_date', models.DateField()),
                ('sell_price', models.PositiveIntegerField()),
            ],
        ),
        migrations.CreateModel(
            name='Strategy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(default=django.utils.timezone.now)),
                ('is_tax_sheltered', models.BooleanField(default=False)),
            ],
        ),
        migrations.CreateModel(
            name='StrategyAdjustment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(verbose_name=django.utils.timezone.now)),
                ('quantity', models.PositiveSmallIntegerField()),
                ('unit_amount', models.IntegerField()),
                ('type', models.IntegerField(choices=[(1, 'Trading Fee'), (2, 'Option Commission'), (3, 'Dividend')], default=1)),
                ('note', models.TextField(blank=True, null=True)),
                ('strategy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='strategy_ledger.Strategy')),
            ],
        ),
        migrations.CreateModel(
            name='StrategyAlert',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=50)),
                ('settings', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True)),
                ('frequency', models.IntegerField(choices=[(strategy_ledger.models.AlertFrequencyType(1), 'On Demand'), (strategy_ledger.models.AlertFrequencyType(2), 'Hourly'), (strategy_ledger.models.AlertFrequencyType(3), 'Daily'), (strategy_ledger.models.AlertFrequencyType(4), 'Weekly'), (strategy_ledger.models.AlertFrequencyType(5), 'Bi-Weekly'), (strategy_ledger.models.AlertFrequencyType(6), 'Monthly')], default=1)),
                ('note', models.TextField(blank=True, null=True)),
            ],
        ),
        migrations.AddField(
            model_name='strategy',
            name='alerts',
            field=models.ManyToManyField(to='strategy_ledger.StrategyAlert'),
        ),
        migrations.AddField(
            model_name='securityposition',
            name='strategy',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='strategy_ledger.Strategy'),
        ),
        migrations.AddField(
            model_name='optionposition',
            name='strategy',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='strategy_ledger.Strategy'),
        ),
    ]
