new charts

This commit is contained in:
anon 2022-08-12 09:05:11 -03:00
parent 9bd4cbbe2d
commit e6efb887b0
7 changed files with 713 additions and 261 deletions

View file

@ -5,12 +5,12 @@ from django.db import models
# Create your models here.
class Coin(models.Model):
name = models.CharField(max_length=4)
date = models.DateField()
priceusd = models.FloatField()
pricebtc = models.FloatField()
inflation = models.FloatField()
transactions = models.FloatField()
name = models.CharField(max_length=4, default="0")
date = models.DateField(default="0")
priceusd = models.FloatField(default="0")
pricebtc = models.FloatField(default="0")
inflation = models.FloatField(default="0")
transactions = models.FloatField(default="0")
hashrate = models.FloatField(default="0")
stocktoflow = models.FloatField(default="0")
supply = models.FloatField(default="0")

View file

@ -123,7 +123,7 @@
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapsePrice"
aria-expanded="true" aria-controls="collapsePrice">
<i class="bx bx-dollar"></i>
<span>Price (16)</span>
<span>Price (17)</span>
</a>
<div id="collapsePrice" class="collapse" aria-labelledby="headingPrice"
data-parent="#accordionSidebar">
@ -133,8 +133,7 @@
<a class="collapse-item" href="{% url 'charts:pricelin' %}">Price in Dollars (Lin.)</a>
<a class="collapse-item" href="{% url 'charts:pricesats' %}">Price in Sats (Lin.)</a>
<a class="collapse-item" href="{% url 'charts:fractal' %}">Fractal Multiple</a>
<a class="collapse-item" href="{% url 'charts:inflationfractal' %}">Inflation-Adjusted
Fractal</a>
<a class="collapse-item" href="{% url 'charts:inflationfractal' %}">Inflation-Adjusted Fractal</a>
<a class="collapse-item" href="{% url 'charts:golden' %}">Golden Ratio Multiplier</a>
<a class="collapse-item" href="{% url 'charts:competitors' %}">Performance ($, Log.)</a>
<a class="collapse-item" href="{% url 'charts:competitorslin' %}">Performance ($, Lin.)</a>
@ -146,6 +145,7 @@
<a class="collapse-item" href="{% url 'charts:thermocap' %}">Thermocap Multiple</a>
<a class="collapse-item" href="{% url 'charts:sharpe' %}">Sharpe Ratio</a>
<a class="collapse-item" href="{% url 'charts:deviation' %}">Price Deviation</a>
<a class="collapse-item" href="{% url 'charts:marketcycle' %}">Market Cycle</a>
</div>
</div>
</li>
@ -174,7 +174,7 @@
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTransactions"
aria-expanded="true" aria-controls="collapseTransactions">
<i class="bx bx-transfer"></i>
<span>Transactions (13)</span>
<span>Transactions (14)</span>
</a>
<div id="collapseTransactions" class="collapse" aria-labelledby="headingTransactions"
data-parent="#accordionSidebar">
@ -193,6 +193,7 @@
<a class="collapse-item" href="{% url 'charts:metcalfe_deviation' %}">Metcalfe's Deviation ($)</a>
<a class="collapse-item" href="{% url 'charts:deviation_tx' %}">Transacted Price Deviation</a>
<a class="collapse-item" href="{% url 'charts:transactiondominance' %}">Transaction Dominance</a>
<a class="collapse-item" href="{% url 'charts:shielded' %}">Shielded Transactions</a>
</div>
</div>
</li>

View file

@ -35,31 +35,6 @@
</div>
</div>
<!-- Content Row -->
<div class="row">
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-6 col-md-6 mb-4">
<div class="card border-left-new h-100 py-2">
<div class="card-body">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">
Current Stock-to-flow Multiple</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ now_cycle }}</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-6 col-md-6 mb-4">
<div class="card border-left-new h-100 py-2">
<div class="card-body">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">
Top Stock-to-flow Multiple Last Cycle</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ maximum }}</div>
</div>
</div>
</div>
</div>
<!-- Content Row -->
<div class="row">
<div class="col-xl-11 col-md-6 mb-4">
@ -98,11 +73,7 @@
</button>
</div>
<div class="modal-body">
This chart shows the Stock-to-flow Multiple, which is the comparison between its current price against
its supposed value. When the indicator reaches 100, it suggests
the coin is at the end of its cycle and will now begin a bear market. This indicator is my own
aprimoration of PlanB's model, since for this one I also considered
the coin's supply. The formula is XMR-Supply*Price/(SF-Value*1.500.000);<br>
This chart shows an estimated Market Cycle for Monero, based on its price agains Bitcoin. The lower the more devaluated the coin is, and closer to the end of its Bear Market. Chart provided as courtesy from Cake Wallet and Monero.com. <a href="https://monero.com/charts/cycle" target="_blank">Link.</a><br>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
@ -235,7 +206,7 @@ var layout = {
xanchor: 'auto',
y: 0.98,
yanchor: 'auto',
text: 'Moneroj<br>https://www.moneroj.net',
text: 'Moneroj<br>https://www.moneroj.net<br>Chart provided as courtesy from Cake Wallet and Monero.com',
showarrow: false,
borderwidth: 1,
bordercolor: '#5f5f5f',
@ -268,7 +239,7 @@ var layout = {
yaxis: {
type: "linear",
title: {
text: 'Price / Stock-to-flow',
text: 'Cycle',
font: {
size: 20,
color: 'white'

View file

@ -0,0 +1,412 @@
{% extends 'charts/base.html' %}
{% block header %}
<title>Moneroj.net - Dread Subscribers</title>
{% endblock %}
{% block content %}
<!-- Content Wrapper -->
<div id="content-wrapper" style="background-color:rgb(48, 44, 41)">
<!-- Main Content -->
<div id="content">
<!-- Begin Page Content -->
<div class="container-fluid"><br>
<div class="row">
<div class="col-xl-12 col-lg-12">
<div class="card" id="graph1">
<div
class="card-header py-3 d-flex flex-row align-items-center justify-content-between text-white">
<h6 class="m-0 text-light">Shielded Transactions</h6>
<div class="dropdown no-arrow">
<a class="dropdown-toggle" href="#" role="button"
onclick="$('#graph1').toggleClass('fullscreen');window.dispatchEvent(new Event('resize'));">
<i class="bx bx-expand text-gray-400"></i>
</a>
</div>
</div>
<div class="card-body pb-0 pt-0 pl-0 pr-0" style="height: 100px;">
<div id="graph" style="height: 100%; width:100%;"></div>
</div>
</div>
<br>
</div>
</div>
<!-- Content Row -->
<div class="row">
<!-- Card -->
<div class="col-xl-6 col-md-6 mb-4">
<div class="card border-left-new h-100 py-2">
<div class="card-body">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">
Monero Monthly Transactions</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ monthly }}</div>
</div>
</div>
</div>
<!-- Card -->
<div class="col-xl-6 col-md-6 mb-4">
<div class="card border-left-new h-100 py-2">
<div class="card-body">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">
Monero Dominance</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ dominance }}%</div>
</div>
</div>
</div>
</div>
<!-- Content Row -->
<div class="row">
<div class="col-xl-11 col-md-6 mb-4">
<div class="alert alert-dark" role="alert">
Not financial advice.
For information about the chart, click the button >
</div>
</div>
<div class="col-xl-1">
<button type="button" class="btn btn-dark btn-block" data-toggle="modal" href="#"
data-target="#id_Modal">
<div class="col-auto">
+
</div>
</button>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
</div>
<!-- End of Content Wrapper -->
<!-- Modal -->
<div class="modal fade" id="id_Modal" tabindex="-1" role="dialog" aria-labelledby="Modal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="Modal">Help about the chart</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Cancelar">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
This chart shows all private transactions from Bitcoin (the ones that go via Whirlpool), Zcash shielded transactions and Monero private transactions. Chart provided as courtesy from Cake Wallet and Monero.com. <a href="https://monero.com/charts/shielded" target="_blank">Link.</a><br><br>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Fim do Modal -->
<!-- Page level plugins -->
<script>
var data1 = {
type: "bar",
name: 'Zcash Shielded Transactions',
x: {{ dates|safe }},
y: {{ values|safe }},
hovertemplate: '%{y}',
line: {
color: '#888888'
,width: 3
},
textposition: 'inside',
marker: {
color: '#888888',
opacity: 0.9,
line: {
color: '#888888',
width: 1
}
}
};
var data1_mobile = {
type: "bar",
name: 'Zcash Shielded Transactions',
x: {{ dates|safe }},
y: {{ values|safe }},
hovertemplate: '%{y}',
line: {
color: '#888888'
,width: 3
},
textposition: 'inside',
marker: {
color: '#888888',
opacity: 0.9,
line: {
color: '#888888',
width: 1
}
}
};
var data2 = {
type: "bar",
name: 'Monero Anonymous Transactions',
x: {{ dates|safe }},
y: {{ values2|safe }},
hovertemplate: '%{y}',
line: {
color: '#dd1d1d'
,width: 3
},
textposition: 'inside',
marker: {
color: '#dd1d1d',
opacity: 0.9,
line: {
color: '#fd4d4d',
width: 1
}
}
};
var data2_mobile = {
type: "bar",
name: 'Monero Anonymous Transactions',
x: {{ dates|safe }},
y: {{ values|safe }},
hovertemplate: '%{y}',
line: {
color: '#dd1d1d'
,width: 3
},
textposition: 'inside',
marker: {
color: '#dd1d1d',
opacity: 0.9,
line: {
color: '#fd4d4d',
width: 1
}
}
};
var data3 = {
type: "bar",
name: 'Bitcoin Whirlpool uxt0s',
x: {{ dates|safe }},
y: {{ values3|safe }},
hovertemplate: '%{y}',
line: {
color: '#ffd311'
,width: 3
},
textposition: 'inside',
marker: {
color: '#ffd311',
opacity: 0.9,
line: {
color: '#fff331',
width: 1
}
}
};
var data3_mobile = {
type: "bar",
name: 'Bitcoin Whirlpool uxt0s',
x: {{ dates|safe }},
y: {{ values3|safe }},
hovertemplate: '%{y}',
line: {
color: '#ffd311'
,width: 3
},
textposition: 'inside',
marker: {
color: '#ffd311',
opacity: 0.9,
line: {
color: '#fff331',
width: 1
}
}
};
var data = [data1, data2, data3];
var data_mobile = [data1_mobile, data2_mobile, data3_mobile];
var layout = {
plot_bgcolor:"#252221",
paper_bgcolor:"#252221",
annotations: [
{
xref: 'paper',
yref: 'paper',
x: 0.02,
xanchor: 'auto',
y: 0.98,
yanchor: 'auto',
text: 'Moneroj<br>https://www.moneroj.net<br>Chart provided as courtesy from Cake Wallet and Monero.com',
showarrow: false,
borderwidth: 1,
bordercolor: '#5f5f5f',
bgcolor: '#333333',
borderpad: 5,
align: 'center',
font: {
color: "white",
size: 12
}
}],
separators: ",.",
legend: {
x: 0.02,
y: 0.50,
bgcolor: '#333333',
bordercolor: '#5f5f5f',
borderwidth: 1,
font: {
color: 'white',
size: 12
},
traceorder: 'normal',
xanchor: 'auto',
yanchor: 'auto'
},
hoverlabel: {
namelength: -1
},
yaxis: {
type: "linear",
title: {
text: 'Transactions',
font: {
size: 20,
color: 'white'
}
},
tickformat :",.0f"
,nticks: 10
,tickfont: {
color: "#ffffff"
,size: 12
}
,gridcolor: "#333333"
},
xaxis: {
hoverformat: "%Y-%m",
showgrid: true,
type: 'date',
nticks: 10
,tickfont: {
color: "#dddddd"
,size: 13
}
,gridcolor: "#333333"
,zeroline: true
},
margin: {
l: 120,
r: 60,
b: 35,
t: 10,
pad: 4
}
};
var layout_mobile = {
plot_bgcolor:"black",
paper_bgcolor:"black",
separators: ",.",
hoverlabel: {
namelength: -1
},
legend: {
x: 0.02,
y: 0.98,
bgcolor: '#000000',
bordercolor: '#5f5f5f',
borderwidth: 1,
font: {
color: 'white',
size: 5
},
traceorder: 'normal',
xanchor: 'auto',
yanchor: 'auto'
},
showlegend: false,
yaxis: {
type: "linear",
tickformat :",.0f"
,nticks: 10
,tickfont: {
color: "#ffffff"
,size: 7
}
,gridcolor: "#444444"
},
xaxis: {
hoverformat: "%Y-%m",
showgrid: true,
type: 'date',
nticks: 10
,tickfont: {
color: "#dddddd"
,size: 13
}
,gridcolor: "#333333"
,zeroline: true
},
margin: {
l: 40,
r: 0,
b: 35,
t: 10,
pad: 0
}
};
function findBootstrapEnvironment() {
let envs = ['xs', 'sm', 'md', 'lg', 'xl'];
let el = document.createElement('div');
document.body.appendChild(el);
let curEnv = envs.shift();
for (let env of envs.reverse()) {
el.classList.add(`d-${env}-none`);
if (window.getComputedStyle(el).display === 'none') {
curEnv = env;
break;
}
}
document.body.removeChild(el);
return curEnv;
}
env_size = findBootstrapEnvironment();
if (env_size == "xs") {
document.getElementById("graph1").style.height="350px";
Plotly.newPlot('graph', data_mobile, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
}
else {
document.getElementById("graph1").style.height="700px";
Plotly.newPlot('graph', data, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
}
</script>
{% endblock %}

View file

@ -91,6 +91,7 @@ urlpatterns = [
path('metcalfesats_deviation/', views.metcalfesats_deviation, name='metcalfesats_deviation'),
path('metcalfe_deviation/', views.metcalfe_deviation, name='metcalfe_deviation'),
path('marketcycle/', views.marketcycle, name='marketcycle'),
path('shielded/', views.shielded, name='shielded'),
# URLs to useful functions on charts/views.py
# Only admins can use these

View file

@ -1026,16 +1026,17 @@ def check_new_social(symbol):
# Update database DailyData with most recent coin data
def update_database(date_from=None, date_to=None):
date_zero = '2014-05-20'
if not(date_from) or not(date_to):
date_to = date.today()
date_from = date_to - timedelta(5)
amount = date_from - datetime.datetime.strptime(date_zero, '%Y-%m-%d')
else:
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))
amount = date_from - datetime.datetime.strptime(date_zero, '%Y-%m-%d')
count = 0
date_aux = date_from
@ -1044,14 +1045,24 @@ def update_database(date_from=None, date_to=None):
date_aux2 = date_aux - timedelta(1)
try:
coin_xmr = Coin.objects.filter(name='xmr').get(date=date_aux)
coin_btc = Coin.objects.filter(name='btc').get(date=date_aux)
coin_dash = Coin.objects.filter(name='dash').get(date=date_aux)
coin_zcash = Coin.objects.filter(name='zec').get(date=date_aux)
coin_grin = Coin.objects.filter(name='grin').get(date=date_aux)
coin_xmr2 = Coin.objects.filter(name='xmr').get(date=date_aux2)
coin_btc = Coin.objects.filter(name='btc').get(date=date_aux)
coin_btc2 = Coin.objects.filter(name='btc').get(date=date_aux2)
try:
coin_dash = Coin.objects.filter(name='dash').get(date=date_aux)
except:
coin_dash = Coin()
try:
coin_zcash = Coin.objects.filter(name='zec').get(date=date_aux)
except:
coin_zcash = Coin()
try:
coin_grin = Coin.objects.filter(name='grin').get(date=date_aux)
except:
coin_grin = Coin()
if coin_btc.inflation == 0 or coin_xmr.inflation == 0:
return count
@ -1091,11 +1102,10 @@ def update_database(date_from=None, date_to=None):
reward = 0.6*(10**12)
inflation = 100*reward*720*365/supply
data.stocktoflow = (100/(inflation))**1.65
if data.color == 0:
v0 = 0.002
delta = (0.015 - 0.002)/(6*365)
data.color = 30*coin_xmr.pricebtc/((amount)*delta + v0)
amount += 1
data.color = 30*coin_xmr.pricebtc/((amount.days)*delta + v0)
amount += timedelta(1)
data.save()
try:
@ -4132,7 +4142,6 @@ 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)
@ -4146,7 +4155,7 @@ def marketcycle(request):
data = Sfmodel.objects.order_by('date')
for item in data:
if item.color > 0:
color.append(item.color)
color.append(item.color - 5)
else:
color.append('')
@ -4161,6 +4170,64 @@ def marketcycle(request):
context = {'dates': dates, 'color': color, 'sell': sell, 'buy': buy, 'now_cycle': now_cycle}
return render(request, 'charts/marketcycle.html', context)
def shielded(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(False)
dt = datetime.datetime.now(timezone.utc).timestamp()
dates = []
values = []
values2 = []
values3 = []
gc = pygsheets.authorize(service_file='service_account_credentials.json')
sh = gc.open('zcash_bitcoin')
wks = sh.worksheet_by_title('Sheet1')
dominance = 0
monthly = 0
values_mat = wks.get_values(start=(3,1), end=(999,5), returnas='matrix')
for k in range(0,len(values_mat)):
if values_mat[k][0] and values_mat[k][3]:
date = values_mat[k][0]
value = values_mat[k][3]
value3 = values_mat[k][4]
if not(value) or not(value):
break
else:
dates.append(date)
values.append(int(value))
values3.append(int(value3))
else:
break
previous_date = 0
coins = Coin.objects.order_by('date').filter(name='xmr')
for date in dates:
value2 = 0
for coin in coins:
aux = str(coin.date)
month = aux.split("-")[0] + '-' + aux.split("-")[1]
if month == date:
if previous_date != coin.date:
value2 += coin.transactions
previous_date = coin.date
values2.append(int(value2))
dominance = 100*int(value2)/(int(value2)+int(value)+int(value3))
monthly = int(value2)
monthly = format(int(monthly),',')
dominance = locale.format('%.2f', dominance, grouping=True)
dt = 'shielded.html ' + locale.format('%.2f', datetime.datetime.now(timezone.utc).timestamp() - dt, grouping=True)+' seconds'
print(dt)
context = {'dates': dates, 'values': values, 'values2': values2, 'values3': values3, "monthly": monthly, "dominance": dominance}
return render(request, 'charts/shielded.html', context)
def thermocap(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(False)