From 3be1c33077ad56499b5186858c47d7ba4d208771 Mon Sep 17 00:00:00 2001 From: Joris W Date: Thu, 27 Aug 2020 09:22:15 +0200 Subject: [PATCH] Restore onTrade() bail-out in a way that works (#2345) This fix undoes #2334 and fixes the problem it tried to fix, the right way, by restoring bailing out of onTrade when an old trade comes in, but this time with the callback that went missing in the changes in https://github.com/DeviaVir/zenbot/commit/17e9758eb0c2179ee81a960ffd83bcb54012c025#diff-a41b519e7979a713e894ef8d1b3fe568R347-R349 . Because of the missing call on the callback function, the async queue chain would break when an old trade came in. This PR restores resuming operations when a trade comes in that belongs to a previous period. The bug, and these changes, affected only those running paper trades in very short timeframes such as 1s or 5s. --- lib/engine.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/engine.js b/lib/engine.js index 2483e410e9..691e97bfbf 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -909,6 +909,9 @@ module.exports = function (s, conf) { } function onTrade(trade, is_preroll, cb) { + if (s.period && trade.time < s.period.time) { + return cb() + } var day = (new Date(trade.time)).getDate() if (s.last_day && day !== s.last_day) { s.day_count++