Add exchange historical endpoint api/historical

This commit is contained in:
Reckless_Satoshi 2022-05-09 10:35:04 -07:00
parent d639ecd706
commit 83c8d80da3
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,5 @@
from django.urls import path 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 = [ urlpatterns = [
path("make/", MakerView.as_view()), path("make/", MakerView.as_view()),
@ -15,4 +15,5 @@ urlpatterns = [
path("price/", PriceView.as_view()), path("price/", PriceView.as_view()),
path("limits/", LimitView.as_view()), path("limits/", LimitView.as_view()),
path("reward/", RewardView.as_view()), path("reward/", RewardView.as_view()),
path("historical/", HistoricalView.as_view()),
] ]

View File

@ -11,6 +11,7 @@ from django.contrib.auth.models import User
from api.serializers import ListOrderSerializer, MakeOrderSerializer, UpdateOrderSerializer, ClaimRewardSerializer, PriceSerializer from api.serializers import ListOrderSerializer, MakeOrderSerializer, UpdateOrderSerializer, ClaimRewardSerializer, PriceSerializer
from api.models import LNPayment, MarketTick, Order, Currency, Profile from api.models import LNPayment, MarketTick, Order, Currency, Profile
from control.models import AccountingDay
from api.logics import Logics from api.logics import Logics
from api.messages import Telegram from api.messages import Telegram
from secrets import token_urlsafe from secrets import token_urlsafe
@ -847,3 +848,16 @@ class LimitView(ListAPIView):
} }
return Response(payload, status.HTTP_200_OK) 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)