added binance withdrawals
This commit is contained in:
parent
116ff2a817
commit
b003610602
7 changed files with 284 additions and 12 deletions
|
@ -152,7 +152,7 @@ class P2Pool(models.Model):
|
|||
return self.date
|
||||
|
||||
class Withdrawal(models.Model):
|
||||
date = models.DateTimeField(auto_now_add=False)
|
||||
date = models.DateTimeField(auto_now_add=True)
|
||||
state = models.BooleanField()
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -8,6 +8,7 @@ from .models import Coin, Social, P2Pool, Dominance, Rank, Sfmodel, DailyData, W
|
|||
from requests import Session
|
||||
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
|
||||
import pygsheets
|
||||
import pytz
|
||||
|
||||
####################################################################################
|
||||
# Reddit api
|
||||
|
@ -122,6 +123,7 @@ def get_binance_withdrawal(symbol):
|
|||
withdrawal.save()
|
||||
return True
|
||||
|
||||
current_date = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
|
||||
response = requests.get(url)
|
||||
result = response.text
|
||||
position = result.find(symbol)
|
||||
|
@ -130,9 +132,7 @@ def get_binance_withdrawal(symbol):
|
|||
result = result[position:position+25]
|
||||
try:
|
||||
result.index('true')
|
||||
print(result.index('true'))
|
||||
print('Enabled')
|
||||
if not(withdrawal.state):
|
||||
if (current_date - withdrawal.date).seconds > 3600:
|
||||
new_withdrawal = Withdrawal()
|
||||
new_withdrawal.state = True
|
||||
new_withdrawal.save()
|
||||
|
@ -140,9 +140,7 @@ def get_binance_withdrawal(symbol):
|
|||
except:
|
||||
try:
|
||||
result.index('false')
|
||||
print(result.index('false'))
|
||||
print('Disabled')
|
||||
if withdrawal.state:
|
||||
if (current_date - withdrawal.date).seconds > 3600:
|
||||
new_withdrawal = Withdrawal()
|
||||
new_withdrawal.state = False
|
||||
new_withdrawal.save()
|
||||
|
|
|
@ -318,7 +318,7 @@
|
|||
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseAdoption"
|
||||
aria-expanded="true" aria-controls="collapseAdoption">
|
||||
<i class="bx bx-store"></i>
|
||||
<span>Adoption (4)</span>
|
||||
<span>Adoption (5)</span>
|
||||
</a>
|
||||
<div id="collapseAdoption" class="collapse" aria-labelledby="headingDarknet"
|
||||
data-parent="#accordionSidebar">
|
||||
|
@ -328,6 +328,7 @@
|
|||
<a class="collapse-item" href="{% url 'charts:merchants' %}">Merchant Acceptance</a>
|
||||
<a class="collapse-item" href="{% url 'charts:merchants_increase' %}">Merchant Increase</a>
|
||||
<a class="collapse-item" href="{% url 'charts:merchants_percentage' %}">Merchant Increase (%)</a>
|
||||
<a class="collapse-item" href="{% url 'charts:withdrawals' %}">Binance Withdrawals</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
|
254
charts/templates/charts/withdrawals.html
Normal file
254
charts/templates/charts/withdrawals.html
Normal file
|
@ -0,0 +1,254 @@
|
|||
{% extends 'charts/base.html' %}
|
||||
|
||||
{% block header %}
|
||||
<title>Moneroj.net - Transaction Count</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<!-- Content Wrapper -->
|
||||
<div id="content-wrapper" style="background-color:rgb(48, 44, 41)">
|
||||
|
||||
<!-- Content Row -->
|
||||
<div class="row" style="height: 92%; margin: 10px 10px 10px 10px;">
|
||||
<div class="card" id="graph1" style="width: 100%; height: 100%;">
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between text-white">
|
||||
<h6 class="m-0 text-light">
|
||||
Binance withdrawal state for Monero (1 = Enabled, 0 = Disabled)
|
||||
</h6>
|
||||
|
||||
<div class="dropdown no-arrow">
|
||||
<a data-toggle="modal" href="#" class="link_graph" data-target="#id_Modal">
|
||||
About this chart?
|
||||
</a>
|
||||
<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" style="width: 100%; height: 100%; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">
|
||||
<div id="graph" style="width: 100%; height: 100%; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</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">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
This chart shows the state of Binance withdrawals for Monero.<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 data3 = {
|
||||
type: "scatter",
|
||||
mode: "lines",
|
||||
name: 'Transactions',
|
||||
x: {{ dates|safe }},
|
||||
y: {{ states|safe }},
|
||||
line: {
|
||||
color: '#dd1d1d'
|
||||
,width: 2
|
||||
},
|
||||
yaxis: "y2"
|
||||
};
|
||||
|
||||
var data3_mobile = {
|
||||
type: "scatter",
|
||||
mode: "lines",
|
||||
name: 'Transactions',
|
||||
x: {{ dates|safe }},
|
||||
y: {{ states|safe }},
|
||||
line: {
|
||||
color: '#dd1d1d'
|
||||
,width: 2
|
||||
},
|
||||
yaxis: "y2"
|
||||
};
|
||||
|
||||
var data = [data3];
|
||||
var data_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',
|
||||
showarrow: false,
|
||||
borderwidth: 1,
|
||||
bordercolor: '#5f5f5f',
|
||||
bgcolor: '#333333',
|
||||
borderpad: 5,
|
||||
align: 'center',
|
||||
font: {
|
||||
color: "white",
|
||||
size: 12
|
||||
}
|
||||
}],
|
||||
separators: ",.",
|
||||
legend: {
|
||||
x: 0.02,
|
||||
y: 0.98,
|
||||
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: 'Current state of withdrawals',
|
||||
font: {
|
||||
size: 20,
|
||||
color: 'white'
|
||||
}
|
||||
},
|
||||
tickformat :",.2f"
|
||||
,nticks: 10
|
||||
,tickfont: {
|
||||
color: "#ffffff"
|
||||
,size: 12
|
||||
}
|
||||
,gridcolor: "#333333"
|
||||
},
|
||||
xaxis: {
|
||||
hoverformat: "%Y-%m-%d",
|
||||
showgrid: true,
|
||||
type: 'date',
|
||||
nticks: 10
|
||||
,tickfont: {
|
||||
color: "#dddddd"
|
||||
,size: 13
|
||||
}
|
||||
,gridcolor: "#333333"
|
||||
,zeroline: true
|
||||
},
|
||||
margin: {
|
||||
l: 100,
|
||||
r: 50,
|
||||
b: 50,
|
||||
t: 20,
|
||||
pad: 10
|
||||
}
|
||||
};
|
||||
|
||||
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",
|
||||
showgrid: true,
|
||||
type: 'date',
|
||||
nticks: 10
|
||||
,tickfont: {
|
||||
color: "#dddddd"
|
||||
,size: 7
|
||||
}
|
||||
,gridcolor: "#444444"
|
||||
,zeroline: true
|
||||
},
|
||||
margin: {
|
||||
l: 100,
|
||||
r: 50,
|
||||
b: 50,
|
||||
t: 20,
|
||||
pad: 10
|
||||
}
|
||||
};
|
||||
|
||||
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") {
|
||||
Plotly.newPlot('graph', data_mobile, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
|
||||
}
|
||||
else {
|
||||
Plotly.newPlot('graph', data, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -97,6 +97,7 @@ urlpatterns = [
|
|||
path('comptransactions/', views.comptransactions, name='comptransactions'),
|
||||
path('p2pool_totalhashes/', views.p2pool_totalhashes, name='p2pool_totalhashes'),
|
||||
path('miningprofitability/', views.miningprofitability, name='miningprofitability'),
|
||||
path('withdrawals/', views.withdrawals, name='withdrawals'),
|
||||
|
||||
# URLs to useful functions on charts/views.py
|
||||
# Only admins can use these
|
||||
|
|
|
@ -5504,3 +5504,21 @@ def monerodominance(request):
|
|||
|
||||
context = {'marketcaps': marketcaps, 'xmr_dominance': xmr_dominance, 'now_marketcap': now_marketcap, 'now_dominance': now_dominance, 'top_marketcap': top_marketcap, 'top_dominance': top_dominance, 'dates': dates}
|
||||
return render(request, 'charts/monerodominance.html', context)
|
||||
|
||||
def withdrawals(request):
|
||||
if request.user.username != "Administrador" and request.user.username != "Morpheus":
|
||||
update_visitors(False)
|
||||
|
||||
states = []
|
||||
dates = []
|
||||
|
||||
withdrawals = Withdrawal.objects.order_by('date')
|
||||
for withdrawal in withdrawals:
|
||||
dates.append(datetime.datetime.strftime(withdrawal.date, '%Y-%m-%d %H'))
|
||||
if withdrawal.state:
|
||||
states.append(1)
|
||||
else:
|
||||
states.append(0)
|
||||
|
||||
context = {'states': states, 'dates': dates}
|
||||
return render(request, 'charts/withdrawals.html', context)
|
|
@ -20,12 +20,12 @@ os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
|
|||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
#Comment for Local:
|
||||
#DEBUG = False
|
||||
#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
DEBUG = False
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
|
||||
#Comment for deploy:
|
||||
DEBUG = True
|
||||
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),]
|
||||
#DEBUG = True
|
||||
#STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),]
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
LOCALE_PATHS = (
|
||||
|
|
Loading…
Reference in a new issue