Commit 341fff60 by ken

depth

parent 5717a89e
...@@ -129,7 +129,7 @@ function subscribe() { ...@@ -129,7 +129,7 @@ function subscribe() {
const lastEventTime = lastEventTimeMap[symbol] || 0; const lastEventTime = lastEventTimeMap[symbol] || 0;
if (depth.timestamp > lastEventTime) { if (depth.timestamp > lastEventTime) {
lastEventTimeMap[symbol] = depth.timestamp; lastEventTimeMap[symbol] = depth.timestamp;
console.log(symbol + '@' + depth.timestamp * 1000 + ' from websocket'); // console.log(symbol + '@' + depth.timestamp * 1000 + ' from websocket');
const asks = depth.asks.reverse(); const asks = depth.asks.reverse();
const bids = depth.bids; const bids = depth.bids;
const publishContent = JSON.stringify({symbol, time: depth.timestamp * 1000}); const publishContent = JSON.stringify({symbol, time: depth.timestamp * 1000});
...@@ -181,7 +181,7 @@ function depthByRest(symbol,callback) { ...@@ -181,7 +181,7 @@ function depthByRest(symbol,callback) {
symbol = symbol.toUpperCase(); symbol = symbol.toUpperCase();
const lastEventTime = lastEventTimeMap[symbol] || 0; const lastEventTime = lastEventTimeMap[symbol] || 0;
if (data.timestamp > lastEventTime || (data.timestamp === lastEventTime && JSON.stringify(data) !== lastDataMap[symbol])) { if (data.timestamp > lastEventTime || (data.timestamp === lastEventTime && JSON.stringify(data) !== lastDataMap[symbol])) {
if (symbol === "BTCUSDT") { if (symbol === "BTCUSDT" && data.timestamp === lastEventTime) {
console.log(symbol + '@' + data.timestamp * 1000 + ' from rest'); console.log(symbol + '@' + data.timestamp * 1000 + ' from rest');
console.log(lastDataMap[symbol]); console.log(lastDataMap[symbol]);
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
......
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