diff --git a/api/serializers.py b/api/serializers.py index fd088afd..5157e5cf 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -1,5 +1,5 @@ from rest_framework import serializers -from .models import Order +from .models import MarketTick, Order class ListOrderSerializer(serializers.ModelSerializer): @@ -132,4 +132,18 @@ class ClaimRewardSerializer(serializers.Serializer): default=None) class PriceSerializer(serializers.Serializer): - pass \ No newline at end of file + pass + +class TickSerializer(serializers.ModelSerializer): + + class Meta: + model = MarketTick + fields = ( + "timestamp", + "currency", + "volume", + "price", + "premium", + "fee", + ) + depth = 1 \ No newline at end of file diff --git a/api/urls.py b/api/urls.py index 84e3d66d..9a8576b2 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, HistoricalView +from .views import MakerView, OrderView, UserView, BookView, InfoView, RewardView, PriceView, LimitView, HistoricalView, TickView urlpatterns = [ path("make/", MakerView.as_view()), @@ -10,10 +10,10 @@ urlpatterns = [ ), path("user/", UserView.as_view()), path("book/", BookView.as_view()), - # path('robot/') # Profile Info path("info/", InfoView.as_view()), path("price/", PriceView.as_view()), path("limits/", LimitView.as_view()), path("reward/", RewardView.as_view()), path("historical/", HistoricalView.as_view()), + path("ticks/", TickView.as_view()), ] diff --git a/api/views.py b/api/views.py index 70cd26fc..f161bbb3 100644 --- a/api/views.py +++ b/api/views.py @@ -11,7 +11,7 @@ from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.models import User -from api.serializers import ListOrderSerializer, MakeOrderSerializer, UpdateOrderSerializer, ClaimRewardSerializer, PriceSerializer, UserGenSerializer +from api.serializers import ListOrderSerializer, MakeOrderSerializer, UpdateOrderSerializer, ClaimRewardSerializer, PriceSerializer, UserGenSerializer, TickSerializer from api.models import LNPayment, MarketTick, OnchainPayment, Order, Currency, Profile from control.models import AccountingDay, BalanceLog from api.logics import Logics @@ -975,6 +975,15 @@ class PriceView(CreateAPIView): return Response(payload, status.HTTP_200_OK) +class TickView(CreateAPIView): + + queryset = MarketTick.objects.all() + serializer_class = TickSerializer + + def get(self, request): + data = self.serializer_class(self.queryset.all(), many=True, read_only=True).data + return Response(data, status=status.HTTP_200_OK) + class LimitView(ListAPIView): def get(self, request): diff --git a/control/tasks.py b/control/tasks.py index d1a925a6..3ddd9938 100644 --- a/control/tasks.py +++ b/control/tasks.py @@ -82,7 +82,7 @@ def do_accounting(): for payout_tx in payouts_tx: escrows_settled += payout_tx.order_paid_TX.trade_escrow.num_satoshis payouts_paid += payout_tx.sent_satoshis - costs += payout_tx.fee + costs += payout_tx.mining_fee_sats # account for those orders where bonds were lost