aboutsummaryrefslogtreecommitdiffstats
path: root/binance.js
diff options
context:
space:
mode:
Diffstat (limited to 'binance.js')
-rw-r--r--binance.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/binance.js b/binance.js
index 8edcc5da..007f7848 100644
--- a/binance.js
+++ b/binance.js
@@ -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);
};
};