aboutsummaryrefslogtreecommitdiffstats
path: root/binance.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2019-10-06 18:32:07 -0700
committerAdam Soltys <[email protected]>2019-10-06 18:32:07 -0700
commit44b420b2bbf6227d3c35658ce65049de014f0809 (patch)
treed9d886e5db17ca5c2d5830eb87e4187f0e5d285a /binance.js
parentb61477bfebe726b9200e10c1e789564a75b865b4 (diff)
downloadcoinos-server-44b420b2bbf6227d3c35658ce65049de014f0809.tar.gz
coinos-server-44b420b2bbf6227d3c35658ce65049de014f0809.zip
get fx rates from fixer api
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);
};
};