Move type field to signal

master
Mark Veidemanis 1 year ago
parent 2ee5f7b937
commit e388624f65
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -72,12 +72,10 @@ class HookForm(RestrictedFormMixin, ModelForm):
fields = (
"name",
"hook",
"type",
)
help_texts = {
"name": "Name of the hook. Informational only.",
"hook": "The URL slug to use for the hook. Make it unique.",
"type": "Whether the hook is used for entering or exiting trades, or determining the trend.",
}
@ -88,12 +86,14 @@ class SignalForm(RestrictedFormMixin, ModelForm):
"name",
"signal",
"hook",
"type",
"direction",
)
help_texts = {
"name": "Name of the signal. Informational only.",
"signal": "The name of the signal in Drakdoo. Copy it from there.",
"hook": "The hook this signal belongs to.",
"type": "Whether the signal is used for entering or exiting trades, or determining the trend.",
"direction": "The direction of the signal. This is used to determine if the signal is a buy or sell.",
}
@ -119,9 +119,9 @@ class AccountForm(RestrictedFormMixin, ModelForm):
class StrategyForm(RestrictedFormMixin, ModelForm):
fieldargs = {
"entry_signals": {"hook__type": "entry"},
"exit_signals": {"hook__type": "exit"},
"trend_signals": {"hook__type": "trend"},
"entry_signals": {"type": "entry"},
"exit_signals": {"type": "exit"},
"trend_signals": {"type": "trend"},
}
class Meta:

@ -0,0 +1,23 @@
# Generated by Django 4.1.3 on 2022-12-07 10:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0045_hook_type'),
]
operations = [
migrations.RemoveField(
model_name='hook',
name='type',
),
migrations.AddField(
model_name='signal',
name='type',
field=models.CharField(choices=[('entry', 'Entry'), ('exit', 'Exit'), ('trend', 'Trend')], default='entry', max_length=255),
preserve_default=False,
),
]

@ -35,7 +35,7 @@ DAY_CHOICES = (
(6, "Saturday"),
(7, "Sunday"),
)
HOOK_TYPE_CHOICES = (
SIGNAL_TYPE_CHOICES = (
("entry", "Entry"),
("exit", "Exit"),
("trend", "Trend"),
@ -174,7 +174,6 @@ class Hook(models.Model):
name = models.CharField(max_length=1024)
hook = models.CharField(max_length=255, unique=True) # hook URL
received = models.IntegerField(default=0)
type = models.CharField(choices=HOOK_TYPE_CHOICES, max_length=255)
def __str__(self):
return f"{self.name} ({self.hook})"
@ -187,6 +186,7 @@ class Signal(models.Model):
hook = models.ForeignKey(Hook, on_delete=models.CASCADE)
direction = models.CharField(choices=DIRECTION_CHOICES, max_length=255)
received = models.IntegerField(default=0)
type = models.CharField(choices=SIGNAL_TYPE_CHOICES, max_length=255)
def __str__(self):
return f"{self.name} ({self.hook.name}) - {self.direction}"

Loading…
Cancel
Save