From 3d9ef5fc5857b92461c11a2272021e54d8eb25c2 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 20 Mar 2022 16:46:36 -0700 Subject: [PATCH] Add limits API endpoint --- api/urls.py | 3 ++- api/views.py | 24 ++++++++++++++++++++++++ robosats/celery/__init__.py | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api/urls.py b/api/urls.py index e402b1c0..67c7e188 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 +from .views import MakerView, OrderView, UserView, BookView, InfoView, RewardView, PriceView, LimitView urlpatterns = [ path("make/", MakerView.as_view()), @@ -13,5 +13,6 @@ urlpatterns = [ # path('robot/') # Profile Info path("info/", InfoView.as_view()), path("price/", PriceView.as_view()), + path("limits/", LimitView.as_view()), path("reward/", RewardView.as_view()), ] diff --git a/api/views.py b/api/views.py index 1be400ac..6acf7425 100644 --- a/api/views.py +++ b/api/views.py @@ -760,4 +760,28 @@ class PriceView(CreateAPIView): except: payload[code] = None + return Response(payload, status.HTTP_200_OK) + +class LimitView(ListAPIView): + + def get(self, request): + + # Trade limits as BTC + min_trade = float(config('MIN_TRADE')) / 100000000 + max_trade = float(config('MAX_TRADE')) / 100000000 + max_bondless_trade = float(config('MAX_TRADE_BONDLESS_TAKER')) / 100000000 + + payload = {} + queryset = Currency.objects.all().order_by('currency') + + for currency in queryset: + code = Currency.currency_dict[str(currency.currency)] + exchange_rate = float(currency.exchange_rate) + payload[currency.currency] = { + 'code': code, + 'min_amount': min_trade * exchange_rate, + 'max_amount': max_trade * exchange_rate, + 'max_bondless_amount': max_bondless_trade * exchange_rate, + } + return Response(payload, status.HTTP_200_OK) \ No newline at end of file diff --git a/robosats/celery/__init__.py b/robosats/celery/__init__.py index 0f4a32c7..407248ae 100644 --- a/robosats/celery/__init__.py +++ b/robosats/celery/__init__.py @@ -39,8 +39,8 @@ app.conf.beat_schedule = { "task": "give_rewards", "schedule": crontab(hour=0, minute=0), }, - "account-day": { # Does accounting for the last day - "task": "account_day", + "do-accounting": { # Does accounting for the last day + "task": "do_accounting", "schedule": crontab(hour=23, minute=55), }, "cache-market-prices": { # Cache market prices every minute