From ddea71de2d1d1f6ba488b3b61e95efd0b133298b Mon Sep 17 00:00:00 2001 From: anon Date: Wed, 10 Aug 2022 23:51:20 -0300 Subject: [PATCH] new charts --- charts/templates/charts/base.html | 4 +- .../templates/charts/metcalfe_deviation.html | 364 ++++++++++++++++++ .../charts/metcalfesats_deviation.html | 364 ++++++++++++++++++ charts/urls.py | 2 + charts/views.py | 64 +++ 5 files changed, 797 insertions(+), 1 deletion(-) create mode 100644 charts/templates/charts/metcalfe_deviation.html create mode 100644 charts/templates/charts/metcalfesats_deviation.html diff --git a/charts/templates/charts/base.html b/charts/templates/charts/base.html index 37654c1..343447a 100644 --- a/charts/templates/charts/base.html +++ b/charts/templates/charts/base.html @@ -174,7 +174,7 @@
@@ -189,6 +189,8 @@ Monthly Percentage (Lin.) Metcalfe's Law (Sats) Metcalfe's Law ($) + Metcalfe's Deviation (Sats) + Metcalfe's Deviation ($) Transacted Price Deviation Transaction Dominance
diff --git a/charts/templates/charts/metcalfe_deviation.html b/charts/templates/charts/metcalfe_deviation.html new file mode 100644 index 0000000..4766ae6 --- /dev/null +++ b/charts/templates/charts/metcalfe_deviation.html @@ -0,0 +1,364 @@ +{% extends 'charts/base.html' %} + +{% block header %} +Moneroj.net - Transaction Count +{% endblock %} + +{% block content %} + + +
+ + +
+ + +

+
+
+
+
+
Metcalfe's Model Deviation (linear chart, percentage and dollars)
+ +
+
+
+
+
+
+
+
+ + + +
+ + +
+
+
+
+ Metcalfe's Model Deviation
+
$ {{ now_metcalfe }}
+
+
+
+ +
+
+
+
+ Metcalfe's Model Deviation
+
{{ now_metcalfe_percentage }} %
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ + +
+ + +
+ + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/charts/templates/charts/metcalfesats_deviation.html b/charts/templates/charts/metcalfesats_deviation.html new file mode 100644 index 0000000..35fbe31 --- /dev/null +++ b/charts/templates/charts/metcalfesats_deviation.html @@ -0,0 +1,364 @@ +{% extends 'charts/base.html' %} + +{% block header %} +Moneroj.net - Transaction Count +{% endblock %} + +{% block content %} + + +
+ + +
+ + +

+
+
+
+
+
Metcalfe's Model Deviation (linear chart, percentage and BTC)
+ +
+
+
+
+
+
+
+
+ + + +
+ + +
+
+
+
+ Metcalfe's Model Deviation
+
{{ now_metcalfe }} BTC
+
+
+
+ +
+
+
+
+ Metcalfe's Model Deviation
+
{{ now_metcalfe_percentage }} %
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ + +
+ + +
+ + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/charts/urls.py b/charts/urls.py index cec60bd..89a4f70 100644 --- a/charts/urls.py +++ b/charts/urls.py @@ -88,6 +88,8 @@ urlpatterns = [ path('p2pool_hashrate/', views.p2pool_hashrate, name='p2pool_hashrate'), path('p2pool_miners/', views.p2pool_miners, name='p2pool_miners'), 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'), # URLs to useful functions on charts/views.py # Only admins can use these diff --git a/charts/views.py b/charts/views.py index e820b36..b72fb94 100644 --- a/charts/views.py +++ b/charts/views.py @@ -3163,6 +3163,70 @@ def metcalfesats(request): context = {'metcalfe': metcalfe, 'dates': dates, 'maximum': maximum, 'now_metcalfe': now_metcalfe, 'color': color, 'prices': prices, 'now_price': now_price} return render(request, 'charts/metcalfesats.html', context) +def metcalfesats_deviation(request): + if request.user.username != "Administrador" and request.user.username != "Morpheus": + update_visitors(False) + + dt = datetime.datetime.now(timezone.utc).timestamp() + data = DailyData.objects.order_by('date') + + metcalfe_percentage = [] + metcalfe = [] + dates = [] + now_metcalfe = 0 + now_metcalfe_percentage = 0 + + for item in data: + dates.append(datetime.datetime.strftime(item.date, '%Y-%m-%d')) + if item.xmr_metcalfebtc < 0.0007 and item.xmr_pricebtc <= 0: + metcalfe.append('') + metcalfe_percentage.append('') + else: + now_metcalfe = item.xmr_metcalfebtc - item.xmr_pricebtc + now_metcalfe_percentage = 100*((item.xmr_metcalfebtc/item.xmr_pricebtc) - 1) + metcalfe.append(now_metcalfe) + metcalfe_percentage.append(now_metcalfe_percentage) + + now_metcalfe = locale.format('%.4f', now_metcalfe, grouping=True) + now_metcalfe_percentage = locale.format('%.0f', now_metcalfe_percentage, grouping=True) + + dt = 'metcalfesats_deviation.html ' + locale.format('%.2f', datetime.datetime.now(timezone.utc).timestamp() - dt, grouping=True)+' seconds' + print(dt) + context = {'metcalfe': metcalfe, 'dates': dates, 'now_metcalfe': now_metcalfe, 'now_metcalfe_percentage': now_metcalfe_percentage, 'metcalfe_percentage': metcalfe_percentage} + return render(request, 'charts/metcalfesats_deviation.html', context) + +def metcalfe_deviation(request): + if request.user.username != "Administrador" and request.user.username != "Morpheus": + update_visitors(False) + + dt = datetime.datetime.now(timezone.utc).timestamp() + data = DailyData.objects.order_by('date') + + metcalfe_percentage = [] + metcalfe = [] + dates = [] + now_metcalfe = 0 + now_metcalfe_percentage = 0 + + for item in data: + dates.append(datetime.datetime.strftime(item.date, '%Y-%m-%d')) + if item.xmr_metcalfeusd < 0.0007 and item.xmr_priceusd <= 0: + metcalfe.append('') + metcalfe_percentage.append('') + else: + now_metcalfe = item.xmr_metcalfeusd - item.xmr_priceusd + now_metcalfe_percentage = 100*((item.xmr_metcalfeusd/item.xmr_priceusd) - 1) + metcalfe.append(now_metcalfe) + metcalfe_percentage.append(now_metcalfe_percentage) + + now_metcalfe = locale.format('%.0f', now_metcalfe, grouping=True) + now_metcalfe_percentage = locale.format('%.0f', now_metcalfe_percentage, grouping=True) + + dt = 'metcalfe_deviation.html ' + locale.format('%.2f', datetime.datetime.now(timezone.utc).timestamp() - dt, grouping=True)+' seconds' + print(dt) + context = {'metcalfe': metcalfe, 'dates': dates, 'now_metcalfe': now_metcalfe, 'now_metcalfe_percentage': now_metcalfe_percentage, 'metcalfe_percentage': metcalfe_percentage} + return render(request, 'charts/metcalfe_deviation.html', context) + def metcalfeusd(request): if request.user.username != "Administrador" and request.user.username != "Morpheus": update_visitors(False)