Commit f9937de0 by ken

depth

parent 44a672cb
...@@ -14,6 +14,7 @@ const accountInfoChannel = "getaccountinfo"; ...@@ -14,6 +14,7 @@ const accountInfoChannel = "getaccountinfo";
const APIKEY = "6b07db0c-dc4f-4a90-9955-665041bdbdbf"; const APIKEY = "6b07db0c-dc4f-4a90-9955-665041bdbdbf";
const APISECRET = "7ac9bcc3-5f0c-4eaf-99c9-80cb6a45165a"; const APISECRET = "7ac9bcc3-5f0c-4eaf-99c9-80cb6a45165a";
const lastEventTimeMap = {}; const lastEventTimeMap = {};
const lastDataMap = {}
let balanceByRestOk = true; let balanceByRestOk = true;
let balanceByWebsocketOk = true; let balanceByWebsocketOk = true;
let currentIpIndex = 0; let currentIpIndex = 0;
...@@ -179,8 +180,9 @@ function depthByRest(symbol,callback) { ...@@ -179,8 +180,9 @@ function depthByRest(symbol,callback) {
const key = symbol.replace('_', '').toUpperCase() + 'DEPTH@zb'; const key = symbol.replace('_', '').toUpperCase() + 'DEPTH@zb';
symbol = symbol.toUpperCase(); symbol = symbol.toUpperCase();
const lastEventTime = lastEventTimeMap[symbol] || 0; const lastEventTime = lastEventTimeMap[symbol] || 0;
if (data.timestamp > lastEventTime) { if (data.timestamp > lastEventTime || (data.timestamp === lastEventTime && JSON.stringify(data) != JSON.stringify(lastDataMap[symbol]))) {
lastEventTimeMap[symbol] = data.timestamp; lastEventTimeMap[symbol] = data.timestamp;
lastDataMap[symbol] = data;
console.log(symbol + '@' + data.timestamp * 1000 + ' from rest'); console.log(symbol + '@' + data.timestamp * 1000 + ' from rest');
const publishContent = JSON.stringify({symbol, time: data.timestamp * 1000}); const publishContent = JSON.stringify({symbol, time: data.timestamp * 1000});
const asks = data.asks.reverse(); const asks = data.asks.reverse();
......
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