def historical_price(request):
fiat = request.GET['fiat'].upper()
crypto = request.GET['currency'].upper()
try:
time = arrow.get(request.GET['time']).datetime
except:
return http.JsonResponse({'error': "Invalid Time argument"}, status=400)
try:
price = PriceTick.nearest(crypto, fiat, time)
except PriceTick.DoesNotExist:
return http.JsonResponse(
{'error': "Can't get historical price for %s->%s" % (fiat, crypto)},
status=400
)
try:
naive_time = time.replace(tzinfo=None)
price['estimated_supply'] = SupplyEstimator(crypto).calculate_supply(at_time=naive_time)
except NotImplementedError:
pass
price['currency'] = crypto
return http.JsonResponse(price)
评论列表
文章目录