{% extends 'base.html' %}
{% block title %}{{frequency}}{% endblock %}
{% block include_scripts %}
{% endblock %}
{% block scripts %}
function isInt(n){
return Number(n) === n && n % 1 === 0;
}
function isFloat(n) {
return Number(n) === n && n % 1 !== 0;
}
var socket = io.connect('http://127.0.0.1:5000/{{frequency}}');
socket.on('ticker', function(json) {
const list = {{attributes|safe}}
for (let i = 0; i < list.length; i++) {
var _attr = list[i].split(' ').join('_').toLowerCase()
var val = json[_attr]
if (val == null) {
continue
}
var _id = '#' + json.source + '_' + json.symbol.toLowerCase() + '_' + _attr + '_' + json.frequency;
if (_attr == 'price' || _attr == 'volume_24h') {
var precision = (val + "").split(".")
var frac_digits = 2
if (_attr == 'price') {
if (precision.length > 1) {
frac_digits = precision[1].length
}
}
const price_formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: frac_digits,
})
val = price_formatter.format(val)
} else if (_attr == 'number_trades_24h') {
val = numeral(val).format('0,0');
} else if (isFloat(json[_attr])) {
val = numeral(val).format('0,0.00');
}
var color = (json.price_change_percent > 0) ? "#e3ffe2" : "#ffe2e2";
if (_attr == 'price') {
$(_id).effect("highlight", {color: color, queue: false}, 1100, "slow");
}
if (_attr == 'price_change_percent') {
$(_id).css("color", (json.price_change_percent > 0) ? "green" : "red");
}
$(_id).html(val);
}
});
{% endblock %}
{% block body %}
{% with url='ticker', params=dict() %}
{% include 'snippets/menu.html' %}
{% endwith %}
{% for i in symbols_per_exchange %}
{% for exchange, d in i.items() %}
{% if d['pairs']%}
{% for att in attributes %} | {{att}} | {% endfor %}
---|---|
{{c}}-{{r}} | {% for att in attributes %}- | {% endfor %}