Implement more detailed link group withdrawal simulations

This commit is contained in:
2023-05-05 14:39:02 +01:00
parent 35607898f0
commit 0be1b98072
7 changed files with 157 additions and 47 deletions

View File

@@ -43,20 +43,27 @@ class Money(object):
)
self.es = client
async def check_all(self, user=None, nordigen=None, agora=None):
async def check_all(self, user=None, link_group=None, nordigen=None, agora=None):
"""
Run all the balance checks that output into ES in another thread.
"""
# TODO: pass link group instead
if not all([user, nordigen, agora]):
if not all([nordigen, agora]):
raise Exception
if not any([user, link_group]):
raise Exception
# I hate circular dependencies
self.nordigen = nordigen
self.agora = agora
aggregators = Aggregator.objects.filter(user=user, enabled=True)
platforms = Platform.objects.filter(user=user, enabled=True)
cast = {}
if user is not None:
cast["user"] = user
if link_group is not None:
cast["link_group"] = link_group
aggregators = Aggregator.objects.filter(enabled=True, **cast)
platforms = Platform.objects.filter(enabled=True, **cast)
total = await self.get_total(aggregators, platforms, trades=True)