Show trades

This commit is contained in:
2023-03-10 00:23:05 +00:00
parent 1e7d8f6c8d
commit fa7ea66c65
12 changed files with 236 additions and 16 deletions

View File

@@ -11,16 +11,37 @@ from mixins.views import ( # ObjectRead,
)
from two_factor.views.mixins import OTPRequiredMixin
# from core.clients.platforms.agora import AgoraClient
from core.clients.platforms.agora import AgoraClient
from core.forms import PlatformForm
from core.models import Platform
from core.util import logs
# from core.views.helpers import synchronize_async_helper
from core.views.helpers import synchronize_async_helper
log = logs.get_logger(__name__)
class PlatformTrades(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
list_template = "partials/platform-trades.html"
page_title = "List of trades"
list_url_name = "trades"
list_url_args = ["type"]
context_object_name_singular = "trade"
context_object_name = "trades"
def get_queryset(self, **kwargs):
platforms = Platform.get_for_user(self.request.user)
total_trades = {}
for platform in platforms:
run = synchronize_async_helper(AgoraClient(platform))
dash = synchronize_async_helper(run.wrap_dashboard())
print("DASH", dash)
total_trades[platform.name] = dash
return total_trades
class PlatformList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
list_template = "partials/platform-list.html"
model = Platform