diff --git a/commands/sim.js b/commands/sim.js index 10707d6326..4659d355aa 100644 --- a/commands/sim.js +++ b/commands/sim.js @@ -295,6 +295,10 @@ module.exports = function (program, conf) { setImmediate(async () => await getNext()) } + if(totalTrades === 0) { + onCollectionCursorEnd() + } + collectionCursorStream.on('data', function(trade) { lastTrade = trade numTrades++ diff --git a/lib/engine.js b/lib/engine.js index 31f3cd76dc..85b6d6ccd2 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -979,12 +979,12 @@ module.exports = function (s, conf) { update: onTrades, exit: function (cb) { if(tradeProcessingQueue.length()){ - tradeProcessingQueue.drain = () => { + tradeProcessingQueue.drain(() => { if(s.strategy.onExit) { s.strategy.onExit.call( s.ctx, s ) } cb() - } + }) } else { if(s.strategy.onExit) { s.strategy.onExit.call( s.ctx, s )