Coverage for django_napse/simulations/models/simulations/managers/simulation_queue.py: 100%
11 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 datetime import datetime
3from django.apps import apps
4from django.db import models
7class SimulationQueueManager(models.Manager):
8 def create(
9 self,
10 space,
11 bot,
12 start_date: datetime,
13 end_date: datetime,
14 investments: dict,
15 ):
16 SimulationQueueInvestedCurrency = apps.get_model("django_napse_simulations", "SimulationQueueInvestedCurrency")
17 queue = self.model(
18 space=space,
19 bot=bot,
20 start_date=start_date,
21 end_date=end_date,
22 )
23 queue.save()
24 for ticker, investment in investments.items():
25 SimulationQueueInvestedCurrency.objects.create(
26 owner=queue,
27 ticker=ticker,
28 amount=investment,
29 )
30 return queue