diff --git a/core/models.py b/core/models.py index 8e5dc6f..ff154c0 100644 --- a/core/models.py +++ b/core/models.py @@ -112,6 +112,9 @@ class Account(models.Model): supported_symbols = models.JSONField(default=list) instruments = models.JSONField(default=list) currency = models.CharField(max_length=255, null=True, blank=True) + riskmodel = models.ForeignKey( + "core.RiskModel", on_delete=models.SET_NULL, null=True, blank=True + ) def __str__(self): name = f"{self.name} ({self.exchange})" @@ -375,20 +378,11 @@ class NotificationSettings(models.Model): return f"Notification settings for {self.user}" -# class Perms(models.Model): -# class Meta: -# permissions = ( -# ("bypass_hashing", "Can bypass field hashing"), # -# ("bypass_blacklist", "Can bypass the blacklist"), # -# ("bypass_encryption", "Can bypass field encryption"), # -# ("bypass_obfuscation", "Can bypass field obfuscation"), # -# ("bypass_delay", "Can bypass data delay"), # -# ("bypass_randomisation", "Can bypass data randomisation"), # -# ("post_irc", "Can post to IRC"), -# ("post_discord", "Can post to Discord"), -# ("query_search", "Can search with query strings"), # -# ("use_insights", "Can use the Insights page"), -# ("index_int", "Can use the internal index"), -# ("index_meta", "Can use the meta index"), -# ("restricted_sources", "Can access restricted sources"), -# ) +class RiskModel(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + name = models.CharField(max_length=255) + description = models.TextField(null=True, blank=True) + # Maximum amount of money to have lost from the initial balance to stop trading + maximum_loss_ratio = models.FloatField(default=0.05) + # Maximum amount of money to risk on all open trades + maximum_risk_ratio = models.FloatField(default=0.05) diff --git a/core/templates/base.html b/core/templates/base.html index 17a0ada..80fe54e 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -254,6 +254,9 @@ Trading Times + + Risk Management +