HOW TO add currency symbol to live data?

youveggie

Power Member
Joined
Nov 13, 2017
Messages
521
Reaction score
379
So im trying to implement live data to my project - im getting a live price from Binance using WebSockets, but how do I actually add $, €, or whatever currency symbol to my live price?
Maybe the simplest way is just to add the symbol separately (not from the API they provide, how can do I do that?)


thanks and have a great weekend all!
 
this is the code I have:

let wsbtceur = new WebSocket('wss://stream.binance.com:9443/ws/btceur@trade');
let stockPriceElementBtceur = document.getElementById('live-price-btc-eur')
let lastPriceBtceur = null;
wsbtceur.onmessage = (event) => {
let stockObject = JSON.parse(event.data)
let price = parseFloat(stockObject.p).toFixed(2);
stockPriceElementBtceur.innerText = parseFloat(stockObject.p).toFixed(2);
stockPriceElementBtceur.style.color = !lastPriceBtceur || lastPriceBtceur === price ? 'black' : price > lastPriceBtceur ? 'green' : 'red';
stockPriceElementBtceur.style.backgroundColor= 'rgb(211, 210, 210)';
lastPriceBtceur = price;
}
 
Still haven’t found solution, i know this probably is dead simple.. :D
 
solo thread :D LOL!

SOLVED!
Just added another <p> element to the div + wrote new function like so:
const livePrice = {
euro__sign: "&#128",
live__euro: function() {
return this.euro__sign;
}
}
document.getElementById("euro").innerHTML = livePrice.live__euro();

mods, please close this solo thread :D
 
Back
Top