Add more hooks to active management
This commit is contained in:
@@ -65,6 +65,19 @@ MAPPING_CHOICES = (
|
||||
(3, "Bearish"),
|
||||
)
|
||||
|
||||
CLOSE_NOTIFY_CHOICES = (
|
||||
("none", "None"),
|
||||
("close", "Close violating trades"),
|
||||
("notify", "Notify only"),
|
||||
)
|
||||
|
||||
ADJUST_CLOSE_NOTIFY_CHOICES = (
|
||||
("none", "None"),
|
||||
("close", "Close violating trades"),
|
||||
("notify", "Notify only"),
|
||||
("adjust", "Adjust violating trades"),
|
||||
)
|
||||
|
||||
|
||||
class Plan(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
@@ -395,6 +408,12 @@ class Strategy(models.Model):
|
||||
"core.OrderSettings",
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
active_management_policy = models.ForeignKey(
|
||||
"core.ActiveManagementPolicy",
|
||||
on_delete=models.PROTECT,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "strategies"
|
||||
@@ -493,3 +512,42 @@ class OrderSettings(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class ActiveManagementPolicy(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField(null=True, blank=True)
|
||||
when_trading_time_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_trends_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_position_size_violated = models.CharField(
|
||||
choices=ADJUST_CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_protection_violated = models.CharField(
|
||||
choices=ADJUST_CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_asset_groups_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_max_open_trades_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_max_open_trades_per_symbol_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_max_loss_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_max_risk_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
when_crossfilter_violated = models.CharField(
|
||||
choices=CLOSE_NOTIFY_CHOICES, max_length=255, default="none"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
Reference in New Issue
Block a user