diff options
Diffstat (limited to 'binance.js')
| -rw-r--r-- | binance.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1,6 +1,6 @@ const WebSocket = require("ws"); -module.exports = app => { +module.exports = (app, socket) => { const binance = new WebSocket( "wss://stream.binance.com:9443/ws/btcusdt@ticker" ); @@ -10,5 +10,15 @@ module.exports = app => { app.set("bid", msg.b); app.set("ask", msg.a); app.set("last", msg.l); + + let fx = app.get("rates"); + if (!fx) return; + let rates = {}; + + Object.keys(fx).map(symbol => { + rates[symbol] = msg.a * fx[symbol]; + }); + + socket.emit("rates", rates); }; }; |
