Implement CRUD for accounts and trades

This commit is contained in:
2022-10-17 18:56:16 +01:00
parent 7779cb8d0e
commit 2bafdf0910
18 changed files with 802 additions and 12 deletions

View File

@@ -66,6 +66,14 @@ class User(AbstractUser):
return plan in plan_list
class Account(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField(max_length=255)
exchange = models.CharField(max_length=255)
api_key = models.CharField(max_length=255)
api_secret = models.CharField(max_length=255)
class Session(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
request = models.CharField(max_length=255, null=True, blank=True)
@@ -81,6 +89,17 @@ class Hook(models.Model):
received = models.IntegerField(default=0)
class Trade(models.Model):
account = models.ForeignKey(Account, on_delete=models.CASCADE)
hook = models.ForeignKey(Hook, on_delete=models.CASCADE, null=True, blank=True)
symbol = models.CharField(max_length=255)
type = models.CharField(max_length=255)
amount = models.FloatField()
price = models.FloatField()
stop_loss = models.FloatField(null=True, blank=True)
take_profit = models.FloatField(null=True, blank=True)
class Callback(models.Model):
hook = models.ForeignKey(Hook, on_delete=models.CASCADE)
title = models.CharField(max_length=1024, null=True, blank=True)