From 9bd4cbbe2d91dfca5df470a36193549356a641f5 Mon Sep 17 00:00:00 2001 From: anon Date: Thu, 11 Aug 2022 16:09:48 -0300 Subject: [PATCH] new chart --- charts/templates/charts/marketcycle.html | 393 +++++++++++++++++++++++ charts/urls.py | 1 + charts/views.py | 35 +- 3 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 charts/templates/charts/marketcycle.html diff --git a/charts/templates/charts/marketcycle.html b/charts/templates/charts/marketcycle.html new file mode 100644 index 0000000..fe4f375 --- /dev/null +++ b/charts/templates/charts/marketcycle.html @@ -0,0 +1,393 @@ +{% extends 'charts/base.html' %} + +{% block header %} +Moneroj.net - Stock to Flow Multiple +{% endblock %} + +{% block content %} + + +
+ + +
+ + +

+
+
+
+
+
Stock-to-flow Multiple (Price / SF Model)
+ +
+
+
+
+
+
+
+
+ + + +
+ +
+
+
+
+ Current Stock-to-flow Multiple
+
{{ now_cycle }}
+
+
+
+ +
+
+
+
+ Top Stock-to-flow Multiple Last Cycle
+
{{ maximum }}
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ + +
+ + +
+ + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/charts/urls.py b/charts/urls.py index 89a4f70..cfae0d2 100644 --- a/charts/urls.py +++ b/charts/urls.py @@ -90,6 +90,7 @@ urlpatterns = [ path('p2pool_totalblocks/', views.p2pool_totalblocks, name='p2pool_totalblocks'), path('metcalfesats_deviation/', views.metcalfesats_deviation, name='metcalfesats_deviation'), path('metcalfe_deviation/', views.metcalfe_deviation, name='metcalfe_deviation'), + path('marketcycle/', views.marketcycle, name='marketcycle'), # URLs to useful functions on charts/views.py # Only admins can use these diff --git a/charts/views.py b/charts/views.py index 819b38d..8aefb3b 100644 --- a/charts/views.py +++ b/charts/views.py @@ -1033,6 +1033,9 @@ def update_database(date_from=None, date_to=None): print(str(date_from) + ' to ' + str(date_to)) date_from = datetime.datetime.strptime(date_from, '%Y-%m-%d') date_to = datetime.datetime.strptime(date_to, '%Y-%m-%d') + + all_coins = Coin.objects.filter(name='xmr').all() + amount = int(len(all_coins)) count = 0 date_aux = date_from @@ -1091,7 +1094,8 @@ def update_database(date_from=None, date_to=None): if data.color == 0: v0 = 0.002 delta = (0.015 - 0.002)/(6*365) - data.color = 30*coin_xmr.pricebtc/(int(coin_xmr.id)*delta + v0) + data.color = 30*coin_xmr.pricebtc/((amount)*delta + v0) + amount += 1 data.save() try: @@ -4128,6 +4132,35 @@ def sfmultiple(request): context = {'dates': dates, 'maximum': maximum, 'stock_to_flow': stock_to_flow, 'now_sf': now_sf, 'buy': buy, 'sell': sell, 'color': color} return render(request, 'charts/sfmultiple.html', context) + +def marketcycle(request): + if request.user.username != "Administrador" and request.user.username != "Morpheus": + update_visitors(False) + + dt = datetime.datetime.now(timezone.utc).timestamp() + dates = [] + color = [] + sell = [] + buy = [] + + data = Sfmodel.objects.order_by('date') + for item in data: + if item.color > 0: + color.append(item.color) + else: + color.append('') + + sell.append(100) + buy.append(0) + dates.append(datetime.datetime.strftime(item.date, '%Y-%m-%d')) + + now_cycle = locale.format('%.2f', item.color, grouping=True) + + dt = 'marketcycle.html ' + locale.format('%.2f', datetime.datetime.now(timezone.utc).timestamp() - dt, grouping=True)+' seconds' + print(dt) + context = {'dates': dates, 'color': color, 'sell': sell, 'buy': buy, 'now_cycle': now_cycle} + return render(request, 'charts/marketcycle.html', context) + def thermocap(request): if request.user.username != "Administrador" and request.user.username != "Morpheus": update_visitors(False)