Add limits API endpoint

This commit is contained in:
Reckless_Satoshi 2022-03-20 16:46:36 -07:00
parent ca79ea9914
commit 3d9ef5fc58
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 28 additions and 3 deletions

View File

@ -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()),
]

View File

@ -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)

View File

@ -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