From 83c8d80da33599636ac38155daf6c57f78d463d2 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 9 May 2022 10:35:04 -0700 Subject: [PATCH] Add exchange historical endpoint api/historical --- api/urls.py | 3 ++- api/views.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/urls.py b/api/urls.py index 67c7e188..84e3d66d 100644 --- a/api/urls.py +++ b/api/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from .views import MakerView, OrderView, UserView, BookView, InfoView, RewardView, PriceView, LimitView +from .views import MakerView, OrderView, UserView, BookView, InfoView, RewardView, PriceView, LimitView, HistoricalView urlpatterns = [ path("make/", MakerView.as_view()), @@ -15,4 +15,5 @@ urlpatterns = [ path("price/", PriceView.as_view()), path("limits/", LimitView.as_view()), path("reward/", RewardView.as_view()), + path("historical/", HistoricalView.as_view()), ] diff --git a/api/views.py b/api/views.py index 50918732..61532ff5 100644 --- a/api/views.py +++ b/api/views.py @@ -11,6 +11,7 @@ from django.contrib.auth.models import User from api.serializers import ListOrderSerializer, MakeOrderSerializer, UpdateOrderSerializer, ClaimRewardSerializer, PriceSerializer from api.models import LNPayment, MarketTick, Order, Currency, Profile +from control.models import AccountingDay from api.logics import Logics from api.messages import Telegram from secrets import token_urlsafe @@ -847,3 +848,16 @@ class LimitView(ListAPIView): } return Response(payload, status.HTTP_200_OK) + +class HistoricalView(ListAPIView): + def get(self, request): + payload = {} + queryset = AccountingDay.objects.all().order_by('day') + + for accounting_day in queryset: + payload[str(accounting_day.day)] = { + 'volume': accounting_day.contracted, + 'num_contracts': accounting_day.num_contracts, + } + + return Response(payload, status.HTTP_200_OK)