Link trading times to strategies
This commit is contained in:
parent
baa8e4fead
commit
69a2b269ad
|
@ -64,6 +64,7 @@ class StrategyForm(ModelForm):
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
"account",
|
"account",
|
||||||
|
"trading_times",
|
||||||
"order_type",
|
"order_type",
|
||||||
"time_in_force",
|
"time_in_force",
|
||||||
"hooks",
|
"hooks",
|
||||||
|
@ -79,6 +80,9 @@ class StrategyForm(ModelForm):
|
||||||
hooks = forms.ModelMultipleChoiceField(
|
hooks = forms.ModelMultipleChoiceField(
|
||||||
queryset=Hook.objects.all(), widget=forms.CheckboxSelectMultiple
|
queryset=Hook.objects.all(), widget=forms.CheckboxSelectMultiple
|
||||||
)
|
)
|
||||||
|
trading_times = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=TradingTime.objects.all(), widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TradeForm(ModelForm):
|
class TradeForm(ModelForm):
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 4.1.3 on 2022-11-25 18:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0030_remove_tradingtime_end_ts_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='strategy',
|
||||||
|
name='trading_times',
|
||||||
|
field=models.ManyToManyField(blank=True, to='core.tradingtime'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -221,11 +221,25 @@ class Callback(models.Model):
|
||||||
symbol = models.CharField(max_length=255)
|
symbol = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
|
||||||
|
class TradingTime(models.Model):
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
description = models.TextField(null=True, blank=True)
|
||||||
|
start_day = models.CharField(choices=DAY_CHOICES, max_length=255)
|
||||||
|
end_day = models.CharField(choices=DAY_CHOICES, max_length=255)
|
||||||
|
start_time = models.TimeField()
|
||||||
|
end_time = models.TimeField()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name} ({self.start_day} at {self.start_time} - {self.end_day} at {self.end_time})"
|
||||||
|
|
||||||
|
|
||||||
class Strategy(models.Model):
|
class Strategy(models.Model):
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
description = models.TextField(null=True, blank=True)
|
description = models.TextField(null=True, blank=True)
|
||||||
account = models.ForeignKey(Account, on_delete=models.CASCADE)
|
account = models.ForeignKey(Account, on_delete=models.CASCADE)
|
||||||
|
trading_times = models.ManyToManyField(TradingTime, blank=True)
|
||||||
order_type = models.CharField(
|
order_type = models.CharField(
|
||||||
choices=TYPE_CHOICES, max_length=255, default="market"
|
choices=TYPE_CHOICES, max_length=255, default="market"
|
||||||
)
|
)
|
||||||
|
@ -246,16 +260,6 @@ class Strategy(models.Model):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class TradingTime(models.Model):
|
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
||||||
name = models.CharField(max_length=255)
|
|
||||||
description = models.TextField(null=True, blank=True)
|
|
||||||
start_day = models.CharField(choices=DAY_CHOICES, max_length=255)
|
|
||||||
end_day = models.CharField(choices=DAY_CHOICES, max_length=255)
|
|
||||||
start_time = models.TimeField()
|
|
||||||
end_time = models.TimeField()
|
|
||||||
|
|
||||||
|
|
||||||
# class Perms(models.Model):
|
# class Perms(models.Model):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# permissions = (
|
# permissions = (
|
||||||
|
|
Loading…
Reference in New Issue