diff options
| author | Adam Soltys <[email protected]> | 2019-10-06 18:32:07 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2019-10-06 18:32:07 -0700 |
| commit | 44b420b2bbf6227d3c35658ce65049de014f0809 (patch) | |
| tree | d9d886e5db17ca5c2d5830eb87e4187f0e5d285a /binance.js | |
| parent | b61477bfebe726b9200e10c1e789564a75b865b4 (diff) | |
| download | coinos-server-44b420b2bbf6227d3c35658ce65049de014f0809.tar.gz coinos-server-44b420b2bbf6227d3c35658ce65049de014f0809.zip | |
get fx rates from fixer api
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); }; }; |
