Skip to content

Commit

Permalink
Add check to end simulation and add drain function properly (DeviaVir…
Browse files Browse the repository at this point in the history
  • Loading branch information
brianunlam authored and Olexiy Buyanskyy committed Feb 2, 2020
1 parent 9b3caf0 commit 0d954a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions commands/sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
4 changes: 2 additions & 2 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,12 +990,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 )
Expand Down

0 comments on commit 0d954a7

Please sign in to comment.