# Generated by Django 2.2.1 on 2019-11-05 02:35

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='Benchmark',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('benchmark', models.CharField(choices=[('^GSPTSE', 'TSX'), ('^G', 'SPY')], max_length=7, verbose_name='Benchmark')),
            ],
        ),
        migrations.CreateModel(
            name='Indicator',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rule_id', models.IntegerField(default=999999999)),
                ('strategy_id', models.IntegerField()),
                ('rank_system_id', models.IntegerField(default=0)),
                ('liquidity_system_id', models.IntegerField(default=0)),
                ('indicator_combination_id', models.IntegerField(default=0)),
                ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_backtest.indicator_set+', to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
        ),
        migrations.CreateModel(
            name='Input_data',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('input_data', models.CharField(choices=[('instrument', 'instrument'), ('bench', 'bench')], max_length=10, verbose_name='Input')),
            ],
        ),
        migrations.CreateModel(
            name='PrimaryRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('strategy_id', models.IntegerField()),
                ('liquidity_system_id', models.IntegerField(default=0)),
                ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_backtest.primaryrule_set+', to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
        ),
        migrations.CreateModel(
            name='Result',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('strategy_id', models.IntegerField(default=0)),
                ('Total_return', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('Benchmark_return', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('Annualized_return', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('Max_drawdown', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('Benchmark_max_drawdown', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('pctwinners', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('Sharpe_ratio', models.DecimalField(decimal_places=2, default=0.0, max_digits=6)),
                ('date', models.DateField(auto_now_add=True)),
            ],
        ),
        migrations.CreateModel(
            name='SellRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('active', models.IntegerField(default=1)),
                ('sellrules', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sellrules', to='backtest.PrimaryRule')),
            ],
        ),
        migrations.CreateModel(
            name='Slippage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('slippage', models.CharField(choices=[('Variable', 'Variable')], max_length=8, verbose_name='Slippage')),
            ],
        ),
        migrations.CreateModel(
            name='Universe',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('universe', models.CharField(choices=[('Universe_Listed+Delisted', 'Universe_Listed+Delisted')], max_length=24, verbose_name='Universe')),
            ],
        ),
        migrations.CreateModel(
            name='BarSinceEntry',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Constant',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Rule',
            fields=[
                ('primaryrule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.PrimaryRule')),
                ('title', models.CharField(max_length=100)),
                ('operator', models.CharField(choices=[('==', '=='), ('<', '<'), ('>', '>'), ('<=', '<='), ('>=', '>=')], max_length=2, verbose_name='Operator')),
                ('technical1', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='technical_1', to='backtest.Indicator')),
                ('technical2', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='technical_2', to='backtest.Indicator')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.primaryrule',),
        ),
        migrations.CreateModel(
            name='RuleCombination',
            fields=[
                ('primaryrule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.PrimaryRule')),
                ('title', models.CharField(max_length=100)),
                ('operator', models.CharField(choices=[('and', 'and'), ('or', 'or')], max_length=3, verbose_name='Operator')),
                ('rule1', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rule_1', to='backtest.PrimaryRule')),
                ('rule2', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rule_2', to='backtest.PrimaryRule')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.primaryrule',),
        ),
        migrations.CreateModel(
            name='Tree',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('child_id', models.IntegerField(default=0)),
                ('child_name', models.CharField(max_length=100)),
                ('child_type', models.IntegerField(default=0)),
                ('parent_id', models.IntegerField(default=0)),
                ('permission', models.BooleanField(default=False)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('path', models.CharField(max_length=200)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='BuyRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('active', models.IntegerField(default=1)),
                ('buyrules', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='buyrules', to='backtest.PrimaryRule')),
            ],
        ),
        migrations.CreateModel(
            name='Strategy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30)),
                ('capital', models.IntegerField(default=30000)),
                ('positions', models.IntegerField(default=6)),
                ('commissions', models.DecimalField(decimal_places=2, default=6.99, max_digits=5)),
                ('transaction_type', models.CharField(choices=[('Short', 'Short'), ('Long', 'Long')], max_length=10, verbose_name='Transaction Type')),
                ('frequency', models.CharField(choices=[('Daily', 'Daily'), ('Weekly', 'Weekly')], max_length=10, verbose_name='Frequency')),
                ('rank_rebalance_type', models.CharField(choices=[('Daily', 'Daily'), ('Weekly', 'Weekly'), ('Monthly', 'Monthly'), ('Never', 'Never')], max_length=10, verbose_name='Ranking system rebalance')),
                ('startdate', models.DateField(default=datetime.date(1999, 1, 1), verbose_name='StartDate')),
                ('enddate', models.DateField(default=datetime.date(2018, 12, 31), verbose_name='EndDate')),
                ('state', models.CharField(default='red', max_length=10)),
                ('benchmark', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='backtest.Benchmark')),
                ('buyrule', models.ManyToManyField(related_name='_strategy_buyrule_+', to='backtest.BuyRule')),
                ('results', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='backtest.Result')),
                ('sellrule', models.ManyToManyField(related_name='_strategy_sellrule_+', to='backtest.SellRule')),
                ('universe', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='backtest.Universe')),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
                ('rule', models.ManyToManyField(related_name='_strategy_rule_+', to='backtest.Rule')),
                ('rulecombination', models.ManyToManyField(related_name='_strategy_rulecombination_+', to='backtest.RuleCombination')),
            ],
            options={
                'verbose_name': 'Strategy',
            },
        ),
        migrations.CreateModel(
            name='Sma',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Slope',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Rsi',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Roc',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='PriceDS',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Ppo',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='OpenDS',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='LowDS',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='HighDS',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Ema',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Atrn',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
        migrations.CreateModel(
            name='Adx',
            fields=[
                ('indicator_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='backtest.Indicator')),
                ('period', models.IntegerField()),
                ('coeff', models.DecimalField(decimal_places=5, default=1.0, max_digits=10)),
                ('lag', models.IntegerField(default=0)),
                ('input_data', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backtest.Input_data')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('backtest.indicator',),
        ),
    ]
