Coverage for django_napse/simulations/models/simulations/currency.py: 54%
41 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from django.db import models
4class SimulationInvestedCurrency(models.Model):
5 owner = models.ForeignKey("Simulation", on_delete=models.CASCADE, related_name="investments")
6 ticker = models.CharField(max_length=10)
7 amount = models.FloatField(default=0)
9 class Meta:
10 unique_together = ("owner", "ticker")
12 def __str__(self):
13 return f"SIMULATION INVESTED CURRENCY {self.pk}"
15 def info(self, verbose=True, beacon=""):
16 string = ""
17 string += f"{beacon}Currency ({self.pk=}):\n"
18 string += f"{beacon}Args:\n"
19 string += f"{beacon}\t{self.owner=}\n"
20 string += f"{beacon}\t{self.mbp=}\n"
21 string += f"{beacon}\t{self.ticker=}\n"
22 string += f"{beacon}\t{self.amount=}\n"
24 if verbose: # pragma: no cover
25 print(string)
26 return string
28 @property
29 def testing(self):
30 return self.wallet.testing
33class SimulationQueueInvestedCurrency(models.Model):
34 owner = models.ForeignKey("SimulationQueue", on_delete=models.CASCADE, related_name="investments")
35 ticker = models.CharField(max_length=10)
36 amount = models.FloatField(default=0)
38 class Meta:
39 unique_together = ("owner", "ticker")
41 def __str__(self):
42 return f"SIMULATION QUEUE INVESTED CURRENCY {self.pk}"
44 def info(self, verbose=True, beacon=""):
45 string = ""
46 string += f"{beacon}Currency ({self.pk=}):\n"
47 string += f"{beacon}Args:\n"
48 string += f"{beacon}\t{self.owner=}\n"
49 string += f"{beacon}\t{self.mbp=}\n"
50 string += f"{beacon}\t{self.ticker=}\n"
51 string += f"{beacon}\t{self.amount=}\n"
53 if verbose: # pragma: no cover
54 print(string)
55 return string
57 @property
58 def testing(self):
59 return self.wallet.testing