Commit 9cca8d76 by ken

zb

parent 3fbf179f
const stream = 'wss://api.zb.com:9999/websocket';
const WebSocket = require('ws');
const options = {};
const observerSymbol = ["btcusdt"];
const observerSymbol = ["btcusdt", 'ethusdt', 'ltcusdt', 'eosusdt', 'bccusdt', 'etcusdt', 'qtumusdt', 'hsrusdt', 'xrpusdt'];
const redis = require('redis');
const redisClient = redis.createClient();
const publishKey = "ZB@2";
......@@ -51,9 +51,9 @@ const _subscribe = function(callback, opened_callback = false) {
function subscribe() {
_subscribe((depth) => {
console.log(depth.timestamp * 1000);
const key = depth.channel.replace('_', '').toUpperCase() + '@zb';
const symbol = depth.channel.replace('_depth', '').toUpperCase();
console.log(symbol + '@' + depth.timestamp * 1000 + ' latency=' + (Date.now() - depth.timestamp * 1000) + 'ms');
const publishContent = JSON.stringify({symbol, time: depth.timestamp * 1000})
const depthJson = JSON.stringify({asks: depth.asks.reverse(), bids: depth.bids, symbol})
redisClient.set(key, depthJson);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment